@@ -207,7 +207,7 @@ class Redis(threading.local):
207
207
bool
208
208
),
209
209
string_keys_to_dict (
210
- 'DECRBY HLEN INCRBY LLEN SCARD SDIFFSTORE SINTERSTORE '
210
+ 'DECRBY HLEN INCRBY LINSERT LLEN LPUSHX RPUSHX SCARD SDIFFSTORE SINTERSTORE '
211
211
'SUNIONSTORE ZCARD ZREMRANGEBYRANK ZREMRANGEBYSCORE ZREVRANK' ,
212
212
int
213
213
),
@@ -750,7 +750,16 @@ def lindex(self, name, index):
750
750
end of the list
751
751
"""
752
752
return self .execute_command ('LINDEX' , name , index )
753
-
753
+
754
+ def linsert (self , name , where , refvalue , value ):
755
+ """
756
+ Insert ``value`` in list ``name`` either immediately before or after [``where``] ``refvalue``
757
+
758
+ Returns positive int length of the list on success, -1 if ``refvalue`` is not in the list,
759
+ 0 if ``name`` is not a list.
760
+ """
761
+ return self .execute_command ('LINSERT' , name , where , refvalue , value )
762
+
754
763
def llen (self , name ):
755
764
"Return the length of the list ``name``"
756
765
return self .execute_command ('LLEN' , name )
@@ -762,6 +771,10 @@ def lpop(self, name):
762
771
def lpush (self , name , value ):
763
772
"Push ``value`` onto the head of the list ``name``"
764
773
return self .execute_command ('LPUSH' , name , value )
774
+
775
+ def lpushx (self , name , value ):
776
+ "Push ``value`` onto the head of the list ``name`` if ``name`` exists"
777
+ return self .execute_command ('LPUSHX' , name , value )
765
778
766
779
def lrange (self , name , start , end ):
767
780
"""
@@ -838,6 +851,10 @@ def rpush(self, name, value):
838
851
"Push ``value`` onto the tail of the list ``name``"
839
852
return self .execute_command ('RPUSH' , name , value )
840
853
854
+ def rpushx (self , name , value ):
855
+ "Push ``value`` onto the tail of the list ``name`` if ``name`` exists"
856
+ return self .execute_command ('RPUSHX' , name , value )
857
+
841
858
def sort (self , name , start = None , num = None , by = None , get = None ,
842
859
desc = False , alpha = False , store = None ):
843
860
"""
0 commit comments