Redis Zrevrange command
The Redis Zrevrange command returns the members within a specified range of a 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 ZREVRANGE command is otherwise the same as ZRANGE the command.
Syntax
The basic syntax of the redis Zrevrange command is as follows:
redis 127.0.0.1:6379> ZREVRANGE key start stop [WITHSCORES]
Available Version
= 1.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> ZRANGE salary 0 -1 WITHSCORES # 递增排列
1) "peter"
2) "3500"
3) "tom"
4) "4000"
5) "jack"
6) "5000"
redis 127.0.0.1:6379> ZREVRANGE salary 0 -1 WITHSCORES # 递减排列
1) "jack"
2) "5000"
3) "tom"
4) "4000"
5) "peter"
6) "3500"
