diff --git a/redis/commands/core.py b/redis/commands/core.py index 457b5c8ad4..95e5dd52a8 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -1782,6 +1782,15 @@ def pexpireat(self, name: KeyT, when: AbsExpiryT) -> ResponseT: when = int(time.mktime(when.timetuple())) * 1000 + ms return self.execute_command("PEXPIREAT", name, when) + def pexpiretime(self, key: str) -> int: + """ + Returns the absolute Unix timestamp (since January 1, 1970) in milliseconds + at which the given key will expire. + + For more information check https://redis.io/commands/pexpiretime + """ + return self.execute_command("PEXPIRETIME", key) + def psetex( self, name: KeyT, diff --git a/tests/test_commands.py b/tests/test_commands.py index 46303e50ac..0d3d9e2082 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1248,6 +1248,12 @@ def test_pexpireat_unixtime(self, r): assert r.pexpireat("a", expire_at_seconds) is True assert 0 < r.pttl("a") <= 61000 + @skip_if_server_version_lt("7.0.0") + def test_pexpiretime(self, r): + r.set("a", "foo") + r.pexpireat("a", 33177117420000) + assert r.pexpiretime("a") == 33177117420000 + @skip_if_server_version_lt("2.6.0") def test_psetex(self, r): assert r.psetex("a", 1000, "value")