Redis有序集合命令ZRANK|ZREVRANk|ZRANGE|ZREVRANGE

xiaoxiao2021-02-28  4

一 ZRANk 1 介绍 返回元素的排名(索引) ZRANk key member 2 举例 127.0.0.1:6379> ZRANK fruits 香蕉 (integer) 0 127.0.0.1:6379> ZRANK fruits 番石榴 (integer) 2 127.0.0.1:6379> ZRANK fruits 芒果 (integer) 3 3 图例 二 ZREVRANk 1 介绍 返回元素的逆序排名 ZREVRANk key member 2 举例 127.0.0.1:6379> ZREVRANk fruits 香蕉 (integer) 4 127.0.0.1:6379> ZREVRANk fruits 番石榴 (integer) 2 127.0.0.1:6379> ZREVRANk fruits 芒果 (integer) 1 3 图例 三 ZRANGE 1 介绍 返回指定索引区间元素 ZRANGE key start stop [WITHSCORES] 如果score相同,则按照字典序lexicographical order 排列 默认按照score从小到大,如果需要score从大到小排列,使用ZREVRANGE 2 举例 127.0.0.1:6379> zadd fruits 2.0 xigua 3.2 xiangjiao 4.0 fanshinian 6.8 mangguo 7.0 li (integer) 5 127.0.0.1:6379> ZRANGE fruits 0 2 1) "xigua" 2) "xiangjiao" 3) "fanshinian" 127.0.0.1:6379> ZRANGE fruits -5 -4 1) "xigua" 2) "xiangjiao" 127.0.0.1:6379> ZRANGE fruits 0 -1 1) "xigua" 2) "xiangjiao" 3) "fanshinian" 4) "mangguo" 5) "li" 3 图例 四 ZREVRANGE 1 介绍 返回指定索引区间的元素 ZREVRANGE key start stop [WITHSCORES] 如果score相同,则按照字典序lexicographical order 的逆序排列 默认按照score从大到小,如果需要score从小到大排列,使用ZRANGE 2 举例 127.0.0.1:6379> ZREVRANGE fruits 0 2 1) "li" 2) "mangguo" 3) "fanshinian" 127.0.0.1:6379> ZREVRANGE fruits -5 -4 1) "li" 2) "mangguo" 127.0.0.1:6379> ZREVRANGE fruits 0 -1 1) "li" 2) "mangguo" 3) "fanshinian" 4) "xiangjiao" 5) "xigua" 3 图例
转载请注明原文地址: https://www.6miu.com/read-1599995.html

最新回复(0)