Skip to content

Commit 1f2259f

Browse files
authored
Add support for PEXPIRETIME (#1861)
* add pexpiretime * skip test
1 parent f987a0c commit 1f2259f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

redis/commands/core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,15 @@ def pexpireat(self, name: KeyT, when: AbsExpiryT) -> ResponseT:
18001800
when = int(time.mktime(when.timetuple())) * 1000 + ms
18011801
return self.execute_command("PEXPIREAT", name, when)
18021802

1803+
def pexpiretime(self, key: str) -> int:
1804+
"""
1805+
Returns the absolute Unix timestamp (since January 1, 1970) in milliseconds
1806+
at which the given key will expire.
1807+
1808+
For more information check https://redis.io/commands/pexpiretime
1809+
"""
1810+
return self.execute_command("PEXPIRETIME", key)
1811+
18031812
def psetex(
18041813
self,
18051814
name: KeyT,

tests/test_commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,12 @@ def test_pexpireat_unixtime(self, r):
12541254
assert r.pexpireat("a", expire_at_seconds) is True
12551255
assert 0 < r.pttl("a") <= 61000
12561256

1257+
@skip_if_server_version_lt("7.0.0")
1258+
def test_pexpiretime(self, r):
1259+
r.set("a", "foo")
1260+
r.pexpireat("a", 33177117420000)
1261+
assert r.pexpiretime("a") == 33177117420000
1262+
12571263
@skip_if_server_version_lt("2.6.0")
12581264
def test_psetex(self, r):
12591265
assert r.psetex("a", 1000, "value")

0 commit comments

Comments
 (0)