Redis 有序集合(sorted set)
Redis Zrevrangebyscore 傳回有序集中指定分數區間内的所有的成員。有序內建員按分數值遞減(從大到小)的次序排列。
具有相同分數值的成員按字典序的逆序(reverse lexicographical order )排列。
除了成員按分數值遞減的次序排列這一點外, ZREVRANGEBYSCORE 指令的其他方面和 ZRANGEBYSCORE 指令一樣。
文法
redis Zrevrangebyscore 指令基本文法如下:
redis 127.0.0.1:6379> ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
可用版本
>= 2.2.0
傳回值
指定區間内,帶有分數值(可選)的有序內建員的清單。
執行個體
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 有序集合(sorted set)