diff options
author | Dan Colish <dcolish@gmail.com> | 2011-03-14 15:38:17 -0400 |
---|---|---|
committer | Dan Colish <dcolish@gmail.com> | 2011-03-14 15:38:17 -0400 |
commit | 7a9fea265989916d0db910d3d049e085a43044af (patch) | |
tree | a022e1a46fad8e27278d7cff8518969b559ab1be | |
parent | e4ca183733535222018b86edb4d23697be0f49b8 (diff) | |
parent | 636d2425c08fdf91432cbb82f67a7ccf59e4ef2f (diff) | |
download | redis-py-7a9fea265989916d0db910d3d049e085a43044af.tar.gz |
Merge branch 'andy'
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | redis/client.py | 6 | ||||
-rw-r--r-- | tests/server_commands.py | 6 |
3 files changed, 8 insertions, 5 deletions
@@ -8,6 +8,7 @@ 2.3+. Thanks Stéphane Angel for the fix. * Lock objects now store their timeout value as a float. This allows floats to be used as timeout values. No changes to existing code required. + * WATCH now supports multiple keys. Thanks Rich Schumacher. * 2.2.3 * Added support for Hiredis. To use, simply "pip install hiredis" or "easy_install hiredis". Thanks for Pieter Noordhuis for the hiredis-py diff --git a/redis/client.py b/redis/client.py index 21d59f5..b091e23 100644 --- a/redis/client.py +++ b/redis/client.py @@ -596,14 +596,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") |