Sunday, 12 April 2015

LINDEX key index

Syntax
LINDEX key index
    Returns the element at specific index of the list.

127.0.0.1:6379> lpush ids 2 3 5 7 11 13 17 
(integer) 7 
127.0.0.1:6379> lindex ids 0 
"17" 
127.0.0.1:6379> lindex ids 2 
"11" 
127.0.0.1:6379> lindex ids 6 
"2" 


It supports negative indexes also, -1 means the last element, -2 means the penultimate and so forth.

127.0.0.1:6379> lindex ids -1 
"2" 
127.0.0.1:6379> lindex ids -5 
"11" 
127.0.0.1:6379> lindex ids -7 
"17" 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment