Sunday 12 April 2015

LPUSH key value1 value2 ... valueN

Syntax
LPUSH key value1 value2 ... valueN
Pushes all the values to the head of the list stored at key.

Returns
Returns the length of the list after push operations.
127.0.0.1:6379> lpush welcome you are how 
(integer) 3 
127.0.0.1:6379> lrange welcome 0 2 
1) "how" 
2) "are" 
3) "you" 

When key holds a value that is not a list, an error is returned.

127.0.0.1:6379> set var1 10 
OK 
127.0.0.1:6379> lpush var1 11 12 
(error) WRONGTYPE Operation against a key holding the wrong kind of value 
127.0.0.1:6379> 


It creates list, if list doesn't exist.
127.0.0.1:6379> keys * 
1) "var1" 
2) "welcome" 
127.0.0.1:6379> lpush hello redis hi 
(integer) 2 
127.0.0.1:6379> keys * 
1) "hello" 
2) "var1" 
3) "welcome" 


 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment