English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis Lindex command is used to retrieve elements from the list by index. You can also use negative indices to, -1 Represents the last element in the list, -2 Represents the second-to-last element in the list, and so on.
The basic syntax of the redis Lindex command is as follows:
redis 127.0.0.1:6379> LINDEX KEY_NAME INDEX_POSITION
>= 1.0.0
The element at the specified index in the list. If the specified index value is not within the range of the list, return nil.
redis 127.0.0.1:6379> LPUSH mylist "World" (integer) 1 redis 127.0.0.1:6379> LPUSH mylist "Hello" (integer) 2 redis 127.0.0.1:6379> LINDEX mylist 0 "Hello" redis 127.0.0.1:6379> LINDEX mylist -1 "World" redis 127.0.0.1:6379> LINDEX mylist 3 The index is not within the range of mylist (nil)