diff options
author | Rich Schumacher <rich@digg.com> | 2011-03-04 13:21:14 -0800 |
---|---|---|
committer | Rich Schumacher <rich@digg.com> | 2011-03-04 13:21:14 -0800 |
commit | 8a49e60e11864023e12683837ff9ac41b9a0a781 (patch) | |
tree | 4a037c72855cb6abdcc0218d9045e5db67d20c38 | |
parent | 89705f343adf2b57104e0d02935888bd7949833e (diff) | |
download | redis-py-8a49e60e11864023e12683837ff9ac41b9a0a781.tar.gz |
Add support for multiple keys in a single WATCH call
-rw-r--r-- | redis/client.py | 6 | ||||
-rw-r--r-- | tests/server_commands.py | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/redis/client.py b/redis/client.py index 289f120..3f3617c 100644 --- a/redis/client.py +++ b/redis/client.py @@ -592,14 +592,14 @@ class Redis(threading.local): "Returns the type of key ``name``" return self.execute_command('TYPE', name) - def watch(self, name): + def watch(self, *names): """ - Watches the value at key ``name``, or None of the key doesn't exist + Watches the values at keys ``names``, or None if the key doesn't exist """ if self.subscribed: raise RedisError("Can't call 'watch' from a pipeline'") - return self.execute_command('WATCH', name) + return self.execute_command('WATCH', *names) def unwatch(self): """ diff --git a/tests/server_commands.py b/tests/server_commands.py index fa47726..8cae871 100644 --- a/tests/server_commands.py +++ b/tests/server_commands.py @@ -255,11 +255,13 @@ class ServerCommandsTestCase(unittest.TestCase): def test_watch(self): self.client.set("a", 1) + self.client.set("b", 2) - self.client.watch("a") + self.client.watch("a", "b") pipeline = self.client.pipeline() pipeline.set("a", 2) - self.assertEquals(pipeline.execute(), [True]) + pipeline.set("b", 3) + self.assertEquals(pipeline.execute(), [True, True]) self.client.set("b", 1) self.client.watch("b") |