Redis - 列表 Lpushx 命令



Redis LPUSHX 命令仅当键已存在且持有列表时,才会向存储于键的列表开头插入值。

返回值

整数响应,推入操作后列表的长度。

语法

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

redis 127.0.0.1:6379> LPUSHX KEY_NAME VALUE1.. VALUEN

示例

redis 127.0.0.1:6379> LPUSH list1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> LPUSHX list1 "bar" 
(integer) 2 
redis 127.0.0.1:6379> LPUSHX list2 "bar" 
(integer) 0 
redis 127.0.0.1:6379> LRANGE list1 0 -1 
1) "foo" 
2) "bar" 
redis_lists.htm
广告
© . All rights reserved.