@@ -2892,9 +2892,18 @@ def zadd(self, name, mapping, nx=False, xx=False, ch=False, incr=False,
2892
2892
the existing score will be incremented by. When using this mode the
2893
2893
return value of ZADD will be the new score of the element.
2894
2894
2895
+ ``LT`` Only update existing elements if the new score is less than
2896
+ the current score. This flag doesn't prevent adding new elements.
2897
+
2898
+ ``GT`` Only update existing elements if the new score is greater than
2899
+ the current score. This flag doesn't prevent adding new elements.
2900
+
2895
2901
The return value of ZADD varies based on the mode specified. With no
2896
2902
options, ZADD returns the number of new elements added to the sorted
2897
2903
set.
2904
+
2905
+ ``NX``, ``LT``, and ``GT`` are mutually exclusive options.
2906
+ See: https://redis.io/commands/ZADD
2898
2907
"""
2899
2908
if not mapping :
2900
2909
raise DataError ("ZADD requires at least one element/score pair" )
@@ -2904,7 +2913,9 @@ def zadd(self, name, mapping, nx=False, xx=False, ch=False, incr=False,
2904
2913
raise DataError ("ZADD option 'incr' only works when passing a "
2905
2914
"single element/score pair" )
2906
2915
if nx is True and (gt is not None or lt is not None ):
2907
- raise DataError ("Only one of 'nx', 'lt', or 'gr' may be defined." )
2916
+ raise DataError ("Only one of 'nx', 'lt', or 'gt' may be defined." )
2917
+ if gt is not None and lt is not None :
2918
+ raise DataError ("Only one of 'gt' or 'lt' can be set." )
2908
2919
2909
2920
pieces = []
2910
2921
options = {}
0 commit comments