Redis Sorted Sets: ZREVRANGE
ZREVRANGE key start stop [WITHSCORES]
Redis ZREVRANGE command is used to return the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. The descending lexicographical order is used for elements with equal score.
Syntax:
ZREVRANGE key min max
Available since
1.2.0.
Return Value
Array reply, a list of elements in the specified range (optionally with their scores).
Return Value Type
Array
Example: Redis ZREVRANGE
127.0.0.1:6379> ZADD mycityset 100000 Delhi 850000 Mumbai 700000 Hyderabad 800000 Kolkata (integer) 4 127.0.0.1:6379> ZREVRANGE mycityset 0 -1 WITHSCORES 1) "Mumbai" 2) "850000" 3) "Kolkata" 4) "800000" 5) "Hyderabad" 6) "700000" 7) "Delhi" 8) "100000"
Example: Redis ZREVRANGE: Lookup specific range
127.0.0.1:6379> ZADD mycityset 100000 Delhi 850000 Mumbai 700000 Hyderabad 800000 Kolkata (integer) 4 127.0.0.1:6379> ZREVRANGE mycityset 0 -1 WITHSCORES 1) "Mumbai" 2) "850000" 3) "Kolkata" 4) "800000" 5) "Hyderabad" 6) "700000" 7) "Delhi" 8) "100000" 127.0.0.1:6379> ZREVRANGE mycityset 0 1 WITHSCORES 1) "Mumbai" 2) "850000" 3) "Kolkata" 4) "800000" 127.0.0.1:6379> ZREVRANGE mycityset -2 -1 WITHSCORES 1) "Hyderabad" 2) "700000" 3) "Delhi" 4) "100000"
Previous:
ZREMRANGEBYSCORE
Next:
ZREVRANGEBYLEX
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics