Latest web development tutorials

Redis Zrevrangebyscore command

Redis ordered set (sorted set)

Redis Zrevrangebyscore return to an ordered set of all members of the designated points within the interval. Ordered sets by scores of members of the decrement (descending) arranged in the order.

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, ZREVRANGEBYSCORE command and other aspects ZRANGEBYSCORE command.

grammar

redis Zrevrangebyscore basic command syntax is as follows:

redis 127.0.0.1:6379> ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]

Available versions

> = 2.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> 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"

Redis ordered set (sorted set)