Redis Zrevrange Command

Redis Ordered Set (sorted set)

The Redis Zrevrange command returns the members in the specified interval in the sorted set.

The members are arranged in order of decreasing score value (from largest to smallest).

Members with the same score value are arranged in reverse lexicographical order.

Except for the arrangement of members in descending order of score, other aspects of the ZREVRANGE command are the same asZRANGEthe 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 Versions

>= 1.2.0

Return Value

A list of members in the specified interval, with (optional) score values.

Examples

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"

Redis Ordered Set (sorted set)

Other Extensions