ZSCORE(3valkey)
β¨ 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 π₯
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:
- bzmpop(3valkey)
- bzpopmax(3valkey)
- bzpopmin(3valkey)
- zadd(3valkey)
- zcard(3valkey)
- zcount(3valkey)
- zdiff(3valkey)
- zdiffstore(3valkey)
- zincrby(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)
- zunion(3valkey)
- zunionstore(3valkey)
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
- 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