LINDEX

Syntax
LINDEX key index
Available since:
1.0.0
Time complexity:
O(N) where N is the number of elements to traverse to get to the element at index. This makes asking for the first or the last element of the list O(1).
ACL categories:
@read, @list, @slow,

返回存储在key中的列表中索引为index的元素。 索引从零开始,因此0表示第一个元素,1表示第二个元素,依此类推。 负索引可用于指定从列表尾部开始的元素。 在这里,-1表示最后一个元素,-2表示倒数第二个元素,依此类推。

key处的值不是列表时,将返回错误。

示例

LPUSH mylist "World" LPUSH mylist "Hello" LINDEX mylist 0 LINDEX mylist -1 LINDEX mylist 3

RESP2 回复

以下之一:

RESP3 回复

以下之一:


RATE THIS PAGE
Back to top ↑