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

202 阅读1分钟

Redis ZREMRANGEBYSCORE 命令删除存储在键中的排序集中的所有元素,这些元素的分数介于最小和最大(含)之间。

ZREMRANGEBYSCORE - 返回值

返回删除的元素数量。

ZREMRANGEBYSCORE - 语法

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

redis 127.0.0.1:6379> ZREMRANGEBYSCORE key min max

ZREMRANGEBYSCORE - 示例

redis 127.0.0.1:6379> ZADD myzset 1 b 2 c 3 d 4 e 
(integer) 4 
redis 127.0.0.1:6379> ZREMRANGEBYSCORE myzset -inf (2 
(integer) 1 
redis 127.0.0.1:6379> ZRANGE myzset 0 -1 WITHSCORES 
1) "b" 
2) "2" 
3) "c" 
4) "3" 
5) "d" 
6) "4" 
7) "e" 
8) "5"

参考链接

www.learnfk.com/redis/sorte…