Latest web development tutorials

Redis Zrevrange command

Redis ordered set (sorted set)

Redis Zrevrange command returns an ordered set, member of the specified interval.

Wherein the position of the members in accordance with the point value decreasing (descending) to arrange.

Members have the same point value according to the dictionary order of reverse (reverse lexicographical order) arrangement.

In addition to the members arranged in descending order according to the point value of this outside, ZREVRANGE command and other aspects ZRANGE command.

grammar

redis Zrevrange basic command syntax is as follows:

redis 127.0.0.1:6379> ZREVRANGE key start stop [WITHSCORES]

Available versions

> = 1.2.0

return value

Within a specified range, the list of members of the ordered sets with fractional value (optional) in.

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)