Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
exclusive gt and lt in zadd (redis/redis-py#1533)

Signed-off-by: Andrew-Chen-Wang <[email protected]>
  • Loading branch information
Andrew-Chen-Wang committed Oct 5, 2021
1 parent 57a21bb commit 82e74e6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions aioredis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3193,9 +3193,18 @@ def zadd(
the existing score will be incremented by. When using this mode the
return value of ZADD will be the new score of the element.
``LT`` Only update existing elements if the new score is less than
the current score. This flag doesn't prevent adding new elements.
``GT`` Only update existing elements if the new score is greater than
the current score. This flag doesn't prevent adding new elements.
The return value of ZADD varies based on the mode specified. With no
options, ZADD returns the number of new elements added to the sorted
set.
``NX``, ``LT``, and ``GT`` are mutually exclusive options.
See: https://redis.io/commands/ZADD
"""
if not mapping:
raise DataError("ZADD requires at least one element/score pair")
Expand All @@ -3208,6 +3217,9 @@ def zadd(
)
if nx is True and (gt is not None or lt is not None):
raise DataError("Only one of 'nx', 'lt', or 'gr' may be defined.")
if gt is not None and lt is not None:
raise DataError("Only one of 'gt' or 'lt' can be set.")

pieces: List[EncodableT] = []
options = {}
if nx:
Expand Down

0 comments on commit 82e74e6

Please sign in to comment.