LINDEX

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Get the value at a given index

The usage is lindex key index.
Gets the value at the given index.
From the left, indexes are 0, 1, 2, ...; from the right they are -1, -2, -3, ...

Example

Command>lpush mylist value1 value2 value3 value4
Result>4
Command>lrange mylist 0 -1
Result>0) value4
1) value3
2) value2
3) value1
Command>lindex mylist 0
Result>value4
Command>lindex mylist 1
Result>value3
Command>lindex mylist -1
Result>value1
Command>lindex mylist -2
Result>value2

View animation



Syntax

LINDEX key index

  • Available since version 1.0.0.
  • Time complexity is O(N).
Related commands LSET, LINSERT, LREM
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< LLEN LINDEX LPOS >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.