Redis Zrevrangebyscore command
Redis Zrevrangebyscore returns all members within a specified score range of a sorted set. Sorted set members are ordered by descending score value (from high to low).
Members with the same score are ordered in reverse lexicographical order.
Except that members are ordered by descending score, the ZREVRANGEBYSCORE command is otherwise the same as ZRANGEBYSCORE the command.
Syntax
The basic syntax of the redis Zrevrangebyscore command is as follows:
redis 127.0.0.1:6379> ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
Available Version
= 2.2.0
Return Value
A list of sorted set members within the specified range, with score values (optional).
Example
redis 127.0.0.1:6379> ZADD salary 10086 jack
(integer) 1
redis > ZADD salary 5000 tom
(integer) 1
redis 127.0.0.1:6379> ZADD salary 7500 peter
(integer) 1
redis 127.0.0.1:6379> ZADD salary 3500 joe
(integer) 1
redis 127.0.0.1:6379> ZREVRANGEBYSCORE salary +inf -inf # 逆序排列所有成员
1) "jack"
2) "peter"
3) "tom"
4) "joe"
redis 127.0.0.1:6379> ZREVRANGEBYSCORE salary 10000 2000 # 逆序排列薪水介于 10000 和 2000 之间的成员
1) "peter"
2) "tom"
3) "joe"
