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