summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Hawco <craig.hawco@gmail.com>2010-09-03 11:36:34 -0400
committerCraig Hawco <craig.hawco@gmail.com>2010-09-03 11:36:34 -0400
commit3e92870bec9bbaddfd786c5a4934c84c8a7f3084 (patch)
treecb4e44e83fbb36de326802128d2d6779e8a1b1d2
parent77422cac6c832f3726557ca397884fc3d415ec54 (diff)
downloadredis-py-3e92870bec9bbaddfd786c5a4934c84c8a7f3084.tar.gz
Add UNWATCH as well.
-rw-r--r--redis/client.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py
index 3719d36..893942a 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -219,7 +219,7 @@ class Redis(threading.local):
string_keys_to_dict('ZSCORE ZINCRBY', float_or_none),
string_keys_to_dict(
'FLUSHALL FLUSHDB LSET LTRIM MSET RENAME '
- 'SAVE SELECT SET SHUTDOWN WATCH',
+ 'SAVE SELECT SET SHUTDOWN WATCH UNWATCH',
lambda r: r == 'OK'
),
string_keys_to_dict('BLPOP BRPOP', lambda r: r and tuple(r) or None),
@@ -692,6 +692,15 @@ class Redis(threading.local):
return self.execute_command('WATCH', name)
+ def unwatch(self, name):
+ """
+ Unwatches the value at key ``name``, or None of the key doesn't exist
+ """
+ if self.subscribed:
+ raise RedisError("Can't call 'unwatch' from a pipeline'")
+
+ return self.execute_command('UNWATCH', name)
+
#### LIST COMMANDS ####
def blpop(self, keys, timeout=0):
"""