summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorAndy McCurdy <sedrik@gmail.com>2012-10-07 21:13:45 -0700
committerAndy McCurdy <sedrik@gmail.com>2012-10-07 21:13:45 -0700
commitb4e0e98e9c94a55fd64e5c38e763ec5a26c47f4e (patch)
treeac89433cb26f164f768d0aa3201d22b6ee4d98a4 /redis/client.py
parent7661d4199fa4393a1a55a26c09e921ff7dc98dbc (diff)
parent3b0932b8a84d66a7586e3ae78ce4f5c102db4030 (diff)
downloadredis-py-b4e0e98e9c94a55fd64e5c38e763ec5a26c47f4e.tar.gz
Merge pull request #282 from flupke/pexpire
Added PEXPIRE/PTTL support (redis 2.6.0)
Diffstat (limited to 'redis/client.py')
-rw-r--r--redis/client.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index 104ae85..42a01dd 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -513,6 +513,16 @@ class StrictRedis(object):
time = int(time.total_seconds())
return self.execute_command('EXPIRE', name, time)
+ def pexpire(self, name, time):
+ """
+ Set an expire flag on key ``name`` for ``time`` milliseconds.
+ ``time`` can be represented by an integer or a Python timedelta
+ object.
+ """
+ if isinstance(time, datetime.timedelta):
+ time = int(time.total_seconds()) * 1000
+ return self.execute_command('PEXPIRE', name, time)
+
def expireat(self, name, when):
"""
Set an expire flag on key ``name``. ``when`` can be represented
@@ -661,6 +671,10 @@ class StrictRedis(object):
"Returns the number of seconds until the key ``name`` will expire"
return self.execute_command('TTL', name)
+ def pttl(self, name):
+ "Returns the number of milliseconds until the key ``name`` will expire"
+ return self.execute_command('PTTL', name)
+
def type(self, name):
"Returns the type of key ``name``"
return self.execute_command('TYPE', name)