Skip to content

Commit f04b16b

Browse files
committed
Alter method arguments
1 parent fe1f59c commit f04b16b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

redis/commands/core.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,14 @@ def persist(self, name: KeyT) -> ResponseT:
17751775
"""
17761776
return self.execute_command("PERSIST", name)
17771777

1778-
def pexpire(self, name: KeyT, time: ExpiryT, option: str = None) -> ResponseT:
1778+
def pexpire(
1779+
self,
1780+
name: KeyT,
1781+
time: ExpiryT,
1782+
option: Union[
1783+
Literal["NX"], Literal["XX"], Literal["GT"], Literal["LT"]
1784+
] = None,
1785+
) -> ResponseT:
17791786
"""
17801787
Set an expire flag on key ``name`` for ``time`` milliseconds
17811788
with given ``option``. ``time`` can be represented by an
@@ -1791,6 +1798,11 @@ def pexpire(self, name: KeyT, time: ExpiryT, option: str = None) -> ResponseT:
17911798
"""
17921799
if isinstance(time, datetime.timedelta):
17931800
time = int(time.total_seconds() * 1000)
1801+
1802+
options = ["NX", "XX", "GT", "LT"]
1803+
if option and option not in options:
1804+
raise DataError(f"OPTION must be one of {options}")
1805+
17941806
exp_option = list()
17951807
if option is not None:
17961808
exp_option.append(option)

0 commit comments

Comments
 (0)