ZREVRANGE
Deprecated: use ZRANGE instead.
ZREVRANGE key start stop [WITHSCORES]
- 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
ZREVRANGE returns the members of the sorted set at key between positions
start and stop, both included, ordered from the highest score to the
lowest (ties in reverse lexicographic order). Position 0 is the
highest-scored member, and negative positions count from the end. It is the
same as ZRANGE key start stop REV; new code can use
ZRANGE.
Options
Section titled “Options”| Option | Effect |
|---|---|
WITHSCORES |
Return each member with its score. Must be written in all upper case or all lower case. |
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 empty range | Empty array | Same |
Errors:
WRONGTYPEifkeyholds a value that is not a sorted set.ERR value is not an integer or out of rangeifstartorstopis not an integer.
Examples
Section titled “Examples”127.0.0.1:6379> ZADD board 1 "a" 2 "b" 3 "c"(integer) 3127.0.0.1:6379> ZREVRANGE board 0 11) "c"2) "b"127.0.0.1:6379> ZREVRANGE board 0 -1 WITHSCORES1) "c"2) "3"3) "b"4) "2"5) "a"6) "1"Compatibility
Section titled “Compatibility”Same replies as Redis 7.4 and Valkey 8 for valid input. Extra or
unrecognised trailing arguments are ignored, where Redis and Valkey reply
with a syntax error. HotKV also checks the key’s type before start and
stop.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.