Skip to content

Commit

Permalink
Merge pull request #145 from spyinx/fix-verify-in-getex
Browse files Browse the repository at this point in the history
fix verify params in getex()
  • Loading branch information
aiven-sal authored Dec 6, 2024
2 parents 8d9470d + 3b1f34c commit e74cefa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,8 @@ def test_getdel(self, r):
@skip_if_server_version_lt("6.2.0")
def test_getex(self, r):
r.set("a", 1)
with pytest.raises(valkey.DataError):
r.getex("a", ex=10, px=10)
assert r.getex("a") == b"1"
assert r.ttl("a") == -1
assert r.getex("a", ex=60) == b"1"
Expand Down
4 changes: 2 additions & 2 deletions valkey/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1859,8 +1859,8 @@ def getex(
For more information see https://valkey.io/commands/getex
"""

opset = {ex, px, exat, pxat}
if len(opset) > 2 or len(opset) > 1 and persist:
opvs = sum(op is not None for op in [ex, px, exat, pxat])
if opvs > 1 or (opvs and persist):
raise DataError(
"``ex``, ``px``, ``exat``, ``pxat``, "
"and ``persist`` are mutually exclusive."
Expand Down

0 comments on commit e74cefa

Please sign in to comment.