无涯教程-Redis - ZRANGEBYSCORE 命令函数

53 阅读1分钟

Redis ZRANGEBYSCORE 命令返回键中排序集中的所有元素,其分数介于min和max之间(包括分数等于min或max的元素)。

ZRANGEBYSCORE - 返回值

返回指定分数范围内的元素列表。

ZRANGEBYSCORE - 语法

以下是Redis ZRANGEBYSCORE 命令的基本语法。

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

ZRANGEBYSCORE - 示例

redis 127.0.0.1:6379> ZADD myzset 0 a 1 b 2 c 3 d 4 e 
(integer) 5 
redis 127.0.0.1:6379> ZADD myzset 5 f 6 g 
(integer) 2 
redis 127.0.0.1:6379> ZRANGEBYSCORE myzset 1 2 
1) "b" 
2) "c" 
redis 127.0.0.1:6379> ZRANGEBYSCORE myzset (1 2 
1) "b" 

参考链接

www.learnfk.com/redis/sorte…