YouTip LogoYouTip

Lists Lindex

# Redis Lindex Command [!(#) Redis Lists (List)](#)") The Redis Lindex command is used to retrieve an element from a list by its index. You can also use negative indices, where -1 refers to the last element of the list, -2 refers to the second-to-last element, and so on. ### Syntax The basic syntax for the Redis Lindex command is as follows: redis 127.0.0.1:6379> LINDEX KEY_NAME INDEX_POSITION ### Available Version >= 1.0.0 ### Return Value The element at the specified index position in the list. If the specified index is out of range, returns nil. ### Examples 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 # index is out of range for mylist(nil) [!(#) Redis Lists (List)](#)")
← Lists LinsertLists Brpoplpush β†’