LINSERT

Syntax
LINSERT key <BEFORE | AFTER> pivot element
Available since:
2.2.0
Time complexity:
O(N) where N is the number of elements to traverse before seeing the value pivot. This means that inserting somewhere on the left end on the list (head) can be considered O(1) and inserting somewhere on the right end (tail) is O(N).
ACL categories:
@write, @list, @slow,

在存储在key中的列表中,在参考值pivot之前或之后插入element

key不存在时,它被视为一个空列表,并且不执行任何操作。

key存在但不持有列表值时,将返回错误。

示例

RPUSH mylist "Hello" RPUSH mylist "World" LINSERT mylist BEFORE "World" "There" LRANGE mylist 0 -1

RESP2/RESP3 回复

以下之一:


RATE THIS PAGE
Back to top ↑