Sunday 12 April 2015

LINSERT key BEFORE|AFTER pivot value

Syntax
LINSERT key BEFORE pivot value
    Insert the value into the list just before pivot value.

LINSERT key AFTER pivot value
    Insert the value into the list just after pivot value.

Returns
The length of the list after the insert operation, or -1 if the value pivot not found.
127.0.0.1:6379> rpush ids 1 2 3 5 6 8 10 
(integer) 7 
127.0.0.1:6379> lrange ids 0 6 
1) "1" 
2) "2" 
3) "3" 
4) "5" 
5) "6" 
6) "8" 
7) "10" 
127.0.0.1:6379> linsert ids before 5 4 
(integer) 8 
127.0.0.1:6379> lrange ids 0 7 
1) "1" 
2) "2" 
3) "3" 
4) "4" 
5) "5" 
6) "6" 
7) "8" 
8) "10" 
127.0.0.1:6379> linsert ids after 8 9 
(integer) 9 
127.0.0.1:6379> lrange ids 0 8 
1) "1" 
2) "2" 
3) "3" 
4) "4" 
5) "5" 
6) "6" 
7) "8" 
8) "9" 
9) "10" 
127.0.0.1:6379> linsert ids after 18 9 
(integer) -1 

 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment