(
符号来使用可选的开区间,也就是小于或大于。示例如下:
ZRANGEBYSCORE zset (1 10 #表示 1<score<=10 ZRANGEBYSCORE zset (5 (20 #1<score<20
ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
127.0.0.1:6379> ZADD salary 3000 jack 3500 helen 2880 john 4000 simith 6000 rose (integer) 5 127.0.0.1:6379> ZRANGE salary 0 4 #浏览所有元素 1) "john" 2) "jack" 3) "helen" 4) "simith" 5) "rose" 127.0.0.1:6379> ZRANGEBYSCORE salary 1000 2500 WITHSCORES limit 1 1 #限制返回元素的数量 (empty list or set) 127.0.0.1:6379> ZRANGEBYSCORE salary 1000 4000 WITHSCORES limit 1 1 1) "jack" 2) "3000" 127.0.0.1:6379> ZRANGEBYSCORE salary 1000 4000 WITHSCORES limit 1 4 #偏移量为1,数量为4 1) "jack" 2) "3000" 3) "helen" 4) "3500" 5) "simith" 6) "4000" 127.0.0.1:6379> ZRANGEBYSCORE salary 1000 (4000 WITHSCORES limit 1 4 #添加( 变为开区间 1) "jack" 2) "3000" 3) "helen" 4) "3500"
本文链接:http://task.lmcjl.com/news/17987.html