Skip to content

Commit 3e92870

Browse files
committed
Add UNWATCH as well.
1 parent 77422ca commit 3e92870

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

redis/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class Redis(threading.local):
219219
string_keys_to_dict('ZSCORE ZINCRBY', float_or_none),
220220
string_keys_to_dict(
221221
'FLUSHALL FLUSHDB LSET LTRIM MSET RENAME '
222-
'SAVE SELECT SET SHUTDOWN WATCH',
222+
'SAVE SELECT SET SHUTDOWN WATCH UNWATCH',
223223
lambda r: r == 'OK'
224224
),
225225
string_keys_to_dict('BLPOP BRPOP', lambda r: r and tuple(r) or None),
@@ -692,6 +692,15 @@ def watch(self, name):
692692

693693
return self.execute_command('WATCH', name)
694694

695+
def unwatch(self, name):
696+
"""
697+
Unwatches the value at key ``name``, or None of the key doesn't exist
698+
"""
699+
if self.subscribed:
700+
raise RedisError("Can't call 'unwatch' from a pipeline'")
701+
702+
return self.execute_command('UNWATCH', name)
703+
695704
#### LIST COMMANDS ####
696705
def blpop(self, keys, timeout=0):
697706
"""

0 commit comments

Comments
 (0)