ZREVRANGEBYSCORE
Deprecated: use ZRANGE instead.
ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
- Group
- Sorted set
- Complexity
- O(log(N)+M) where N is the size of the sorted set and M is the number of members returned
- Arity
- -4 (at least 4 words, counting the command name)
- Flags
- read-only
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
ZREVRANGEBYSCORE returns the members of the sorted set at key whose score
is between max and min, from the highest score to the lowest. Note that the
higher bound comes first. It is the same as
ZRANGE key max min BYSCORE REV; new code can use ZRANGE.
Bounds are inclusive unless prefixed with (, and -inf / +inf are allowed.
Options
Section titled “Options”| Option | Effect |
|---|---|
WITHSCORES |
Return each member with its score. |
LIMIT offset count |
Skip offset matching members, then return at most count. A negative count returns all remaining members. |
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Success | Array of members | Same |
With WITHSCORES |
Flat array: member, score, … (scores as bulk strings) | Array of [member, score] pairs, the score a double |
| Key does not exist or nothing in range | Empty array | Same |
Errors are the same as for ZRANGEBYSCORE.
Examples
Section titled “Examples”127.0.0.1:6379> ZADD board 1 "a" 2 "b" 3 "c"(integer) 3127.0.0.1:6379> ZREVRANGEBYSCORE board +inf (11) "c"2) "b"127.0.0.1:6379> ZREVRANGEBYSCORE board 3 1 WITHSCORES LIMIT 0 11) "c"2) "3"Compatibility
Section titled “Compatibility”Same as Redis 7.4 and Valkey 8, where it is also deprecated in favour of
ZRANGE ... BYSCORE REV.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.