Skip to content

Commit

Permalink
Add support for PEXPIRETIME (#1861)
Browse files Browse the repository at this point in the history
* add pexpiretime

* skip test
  • Loading branch information
dvora-h committed Mar 6, 2022
1 parent f987a0c commit 1f2259f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,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,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,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")
Expand Down

0 comments on commit 1f2259f

Please sign in to comment.