Redis Rpush 命令

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

Redis Rpush 命令用于将一个或多个值插入到列表的尾部(最右边)。

如果列表不存在,一个空列表会被创建并执行 RPUSH 操作。 当列表存在但不是列表类型时,返回一个错误。

注意:在 Redis 2.4 版本以前的 RPUSH 命令,都只接受单个 value 值。

语法

redis 127.0.0.1:6379> RPUSH KEY_NAME VALUE1..VALUEN

返回值

执行 RPUSH 操作后,列表的长度。

实例

redis 127.0.0.1:6379> RPUSH mylist "hello"
(integer) 1
redis 127.0.0.1:6379> RPUSH mylist "foo"
(integer) 2
redis 127.0.0.1:6379> RPUSH mylist "bar"
(integer) 3
redis 127.0.0.1:6379> LRANGE mylist 0 -1
1) "hello"
2) "foo"
3) "bar"

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

Head First Design Patterns

Head First Design Patterns

Elisabeth Freeman、Eric Freeman、Bert Bates、Kathy Sierra、Elisabeth Robson / O'Reilly Media / 2004-11-1 / USD 49.99

You're not alone. At any given moment, somewhere in the world someone struggles with the same software design problems you have. You know you don't want to reinvent the wheel (or worse, a flat tire),......一起来看看 《Head First Design Patterns》 这本书的介绍吧!

MD5 加密

MD5 加密

MD5 加密工具

XML 在线格式化

XML 在线格式化

在线 XML 格式化压缩工具

Markdown 在线编辑器

Markdown 在线编辑器

Markdown 在线编辑器