Redis - Sorted Set Zrevrange Command


Advertisements

Redis ZREVRANGE command returns the specified range of elements in the sorted set stored at the key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with an equal score.

Return Value

Array reply, list of elements in the specified range (optionally with their scores).

Syntax

Following is the basic syntax of Redis ZREVRANGE command.

redis 127.0.0.1:6379> ZREVRANGE key min max

Example

redis 127.0.0.1:6379> ZADD myzset 1 b 2 c 3 d 4 e 
(integer) 4 
redis 127.0.0.1:6379> ZREVRANGE myzset 0 -1 
1) "e" 
2) "d" 
3) "c" 
4) "b" 
redis_sorted_sets.htm
Advertisements