LPUSHX

Syntax
LPUSHX key element [element ...]
Available since:
2.2.0
Time complexity:
O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.
ACL categories:
@write, @list, @fast,

如果key已经存在并且持有一个列表,则在存储在key的列表头部插入指定的值。 与LPUSH相反,当key尚不存在时,不会执行任何操作。

示例

LPUSH mylist "World" LPUSHX mylist "Hello" LPUSHX myotherlist "Hello" LRANGE mylist 0 -1 LRANGE myotherlist 0 -1

RESP2/RESP3 回复

Integer reply: the length of the list after the push operation.

历史

  • 从 Redis 版本 4.0.0 开始:接受多个 element 参数。
RATE THIS PAGE
Back to top ↑