Redis Linsert 命令

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

Redis Linsert 命令用于在列表的元素前或者后插入元素。当指定元素不存在于列表中时,不执行任何操作。

当列表不存在时,被视为空列表,不执行任何操作。

如果 key 不是列表类型,返回一个错误。

语法

LINSERT key BEFORE|AFTER pivot value

返回值

如果命令执行成功,返回插入操作完成之后,列表的长度。 如果没有找到指定元素 ,返回 -1 。 如果 key 不存在或为空列表,返回 0 。

实例

redis> RPUSH mylist "Hello"
(integer) 1
redis> RPUSH mylist "World"
(integer) 2
redis> LINSERT mylist BEFORE "World" "There"
(integer) 3
redis> LRANGE mylist 0 -1
1) "Hello"
2) "There"
3) "World"
redis> 

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

Web Caching

Web Caching

Duane Wessels / O'Reilly Media, Inc. / 2001-6 / 39.95美元

On the World Wide Web, speed and efficiency are vital. Users have little patience for slow web pages, while network administrators want to make the most of their available bandwidth. A properly design......一起来看看 《Web Caching》 这本书的介绍吧!

Base64 编码/解码

Base64 编码/解码

Base64 编码/解码

SHA 加密

SHA 加密

SHA 加密工具

HEX HSV 转换工具

HEX HSV 转换工具

HEX HSV 互换工具