ZINCRBY(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– 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 πŸ‘€


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