ZSCORE(3valkey)

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

✨ ZSCORE πŸ’… (from the valkey manual, section 3)

okay bestie, buckle up, because this one is tiny but it's lowkey the moment you've been waiting for πŸŽ€ it's zscore, and yes it lives in the valkey command manual, section 3, right where you left it.


🌸 NAME 🌸

zscore β€” hands you the score of a member inside a sorted set. that's it. that's the whole job. and it does it flawlessly, no cap πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

ZSCORE key member

two little args. one big glow-up. periodt.


πŸ’– DESCRIPTION πŸ’–

so basically: it returns the score of member in the sorted set stored at key. πŸ’«

and if member is not in that sorted set, or if key doesn't exist at all? you get nil back. no drama, no error, just nil floating in like a sad little ghost πŸ‘»

fr fr, nil is the answer in both of those cases β€” missing member, missing key. don't go looking for an error message, there isn't one.

🌈 REPLY 🌈

the reply depends on which protocol you're speaking, and honestly? both are valid. vibe check time:

RESP2 ✨

one of these two things:

  • valkey-protocol(7) Bulk string reply: the score of the member β€” a double-precision floating point number, but wrapped up all cute as a string. πŸ’…
  • valkey-protocol(7) Nil reply: if the member does not exist in the sorted set, or the key does not exist. πŸ’€

RESP3 🫢

also one of two things:

  • valkey-protocol(7) Double reply: the score of the member, and this time it's an actual double-precision floating point number. no string costume, we're being real here. ⭐
  • valkey-protocol(7) Null reply: if the member does not exist in the sorted set, or the key does not exist. 😭

πŸ”₯ COMPLEXITY πŸ”₯

O(1)

constant time, bestie!! it's giving instant. it's giving lightning. it's giving no excuses 🌩️✨


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @fast
  • @read
  • @sortedset

🧚 HISTORY 🧚

  • Available since: 1.2.0 β€” an absolute icon, been here since the early days and still serving πŸŽ€

πŸ“ EXAMPLES πŸ“

look at her go:

127.0.0.1:6379> ZADD myzset 1 "one"
(integer) 1
127.0.0.1:6379> ZSCORE myzset "one"
"1"

add it, score it, slay it. the "1" is a string in RESP2 btw, don't come for me πŸ™ˆ


πŸ’œ SEE ALSO πŸ’œ

the whole sorted-set friend group, all of them, every single one, no member left behind:


okay that's the whole page, bestie 🫢 this was version 9.0.0, dated 2025-10-21 β€” go forth and ZSCORE responsibly, ily, mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from