Skip to content

Commit e74cefa

Browse files
authored
Merge pull request #145 from spyinx/fix-verify-in-getex
fix verify params in getex()
2 parents 8d9470d + 3b1f34c commit e74cefa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tests/test_commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,8 @@ def test_getdel(self, r):
13301330
@skip_if_server_version_lt("6.2.0")
13311331
def test_getex(self, r):
13321332
r.set("a", 1)
1333+
with pytest.raises(valkey.DataError):
1334+
r.getex("a", ex=10, px=10)
13331335
assert r.getex("a") == b"1"
13341336
assert r.ttl("a") == -1
13351337
assert r.getex("a", ex=60) == b"1"

valkey/commands/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,8 +1859,8 @@ def getex(
18591859
For more information see https://valkey.io/commands/getex
18601860
"""
18611861

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

0 commit comments

Comments
 (0)