From 3e92870bec9bbaddfd786c5a4934c84c8a7f3084 Mon Sep 17 00:00:00 2001 From: Craig Hawco Date: Fri, 3 Sep 2010 11:36:34 -0400 Subject: Add UNWATCH as well. --- redis/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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): """ -- cgit v1.2.1