ZINCRBY(3valkey)
π ZINCRBY π
okay bestie, welcome to the Valkey Command Manual page for zincrby β yes it's the ZINCRBY(3valkey) one, we're in the right place, breathe π«Ά
β¨ NAME β¨
zincrby β bumps up the score of a member inside a sorted set. that's it, that's the whole job π
πΈ SYNOPSIS πΈ
ZINCRBY key increment member
π¦ DESCRIPTION π¦
so here's the tea: this command takes the score of member inside the sorted set living at key, and adds increment to it. math. slay. β¨
if member isn't in that sorted set yet? no problem, it just gets added with increment as its score β literally as if its previous score was 0.0. and if key doesn't even exist yet? a whole new sorted set gets created with that one member as its sole member. main character energy fr π
β οΈ if key exists but doesn't hold a sorted set, you get an error back. no cap, don't do that.
the score value needs to be the string representation of a numeric value, and it accepts double precision floating point numbers. and yes bestie, you can absolutely pass a negative value to decrement the score. it goes both ways π
π REPLY π
RESP2
valkey-protocol(7) Bulk string reply: the new score of member, as a double precision floating point number. π
RESP3
valkey-protocol(7) Double reply: the new score of member. π₯
β‘ COMPLEXITY β‘
O(log(N)) where N is the number of elements in the sorted set. fast. iconic. obsessed.
π ACL CATEGORIES π
@fast @sortedset @write
π°οΈ HISTORY π°οΈ
- Available since:
1.2.0β an elder, a legend, a queen π
π EXAMPLES π
127.0.0.1:6379> ZADD myzset 1 "one"
(integer) 1
127.0.0.1:6379> ZADD myzset 2 "two"
(integer) 1
127.0.0.1:6379> ZINCRBY myzset 2 "one"
"3"
127.0.0.1:6379> ZRANGE myzset 0 -1 WITHSCORES
1) "two"
2) "2"
3) "one"
4) "3"
not "one" going from 1 to "3" like that π she ate and left no crumbs fr fr
π SEE ALSO π
bzmpop(3valkey)bzpopmax(3valkey)bzpopmin(3valkey)zadd(3valkey)zcard(3valkey)zcount(3valkey)zdiff(3valkey)zdiffstore(3valkey)zinter(3valkey)zintercard(3valkey)zinterstore(3valkey)zlexcount(3valkey)zmpop(3valkey)zmscore(3valkey)zpopmax(3valkey)zpopmin(3valkey)zrandmember(3valkey)zrange(3valkey)zrangebylex(3valkey)zrangebyscore(3valkey)zrangestore(3valkey)zrank(3valkey)zrem(3valkey)zremrangebylex(3valkey)zremrangebyrank(3valkey)zremrangebyscore(3valkey)zrevrange(3valkey)zrevrangebylex(3valkey)zrevrangebyscore(3valkey)zrevrank(3valkey)zscan(3valkey)zscore(3valkey)zunion(3valkey)zunionstore(3valkey)
and that's the whole page, bestie!! this was version 9.0.0, dated 2025-10-21 β so go forth, increment those scores, and remember: ZINCRBY never misses πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms