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
存在但不持有列表值时,将返回错误。
示例
RESP2/RESP3 回复
以下之一:
- Integer reply: 成功插入操作后的列表长度。
- Integer reply:
0
当键不存在时。 - Integer reply:
-1
当未找到枢轴时。