Redis Lrem 命令

更新时间: 2019-07-07 15:54

Redis Lrem 根据参数 COUNT 的值,移除列表中与参数 VALUE 相等的元素。

COUNT 的值可以是以下几种:

  • count > 0 : 从表头开始向表尾搜索,移除与 VALUE 相等的元素,数量为 COUNT 。
  • count < 0 : 从表尾开始向表头搜索,移除与 VALUE 相等的元素,数量为 COUNT 的绝对值。
  • count = 0 : 移除表中所有与 VALUE 相等的值。

语法

redis 127.0.0.1:6379> LREM KEY_NAME COUNT VALUE

返回值

被移除元素的数量。 列表不存在时返回 0 。

实例

redis> RPUSH mylist "hello"
(integer) 1
redis> RPUSH mylist "hello"
(integer) 2
redis> RPUSH mylist "foo"
(integer) 3
redis> RPUSH mylist "hello"
(integer) 4
redis> LREM mylist -2 "hello"
(integer) 2
redis> LRANGE mylist 0 -1
1) "hello"
2) "foo"
redis> 

查看更多 Redis 列表(List)命令

Head First JavaScript Programming

Head First JavaScript Programming

Eric T. Freeman、Elisabeth Robson / O'Reilly Media / 2014-4-10 / USD 49.99

This brain-friendly guide teaches you everything from JavaScript language fundamentals to advanced topics, including objects, functions, and the browser’s document object model. You won’t just be read......一起来看看 《Head First JavaScript Programming》 这本书的介绍吧!

JSON 在线解析

JSON 在线解析

在线 JSON 格式化工具

RGB HSV 转换

RGB HSV 转换

RGB HSV 互转工具

HSV CMYK 转换工具

HSV CMYK 转换工具

HSV CMYK互换工具