一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Redis ZREVRANGE命令

时间:2026-08-07 12:13:51 编辑:袖梨 来源:一聚教程网

Redis ZREVRANGE 命令返回有序集 key 中,指定区间内的成员。其中成员的位置按 score 值递减(从大到小)来排列。具有相同 score 值的成员按字典序的逆序排列。

除了成员按 score 值降序排列外, ZREVRANGE 命令的其他方面和 ZRANGE 命令相同。

可用版本

ZREVRANGE 命令可用版本:>= 1.2.0

语法

Redis ZREVRANGE 命令的基本语法如下:
ZREVRANGE key start stop [WITHSCORES] 

返回值

指定区间内,带有 score 值(可选)的有序集成员的列表。

命令演示

127.0.0.1:6379> ZADD salary 3000 jack 3500 helen 2880(integer) 3127.0.0.1:6379> ZRANGE salary 0 -1 withscores1) "john"2) "2880"3) "jack"4) "3000"5) "helen"6) "3500"127.0.0.1:6379> ZREVRANGE salary 0 -1 withscores1) "helen"2) "3500"3) "jack"4) "3000"5) "john"6) "2880"

Redis ZREVRANGE命令

热门栏目