summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2010-04-27 21:51:40 -0700
committerAndy McCurdy <andy@andymccurdy.com>2010-04-27 21:51:40 -0700
commit60063e8ef022ea500788a572d7b3c07080557c54 (patch)
treef6c1b927924740dd232520b5c3889ebe05a7ec69 /redis/client.py
parentc3d531e9d279d0d3532267b1d1887ac8e68f5a43 (diff)
downloadredis-py-60063e8ef022ea500788a572d7b3c07080557c54.tar.gz
added pubsub tests
fixed a typo in hmset from the previous commit
Diffstat (limited to 'redis/client.py')
-rw-r--r--redis/client.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py
index 34b55dd..16e357e 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -1024,7 +1024,7 @@ class Redis(threading.local):
"""
items = []
[items.extend(pair) for pair in mapping.iteritems()]
- return self.execute_command('HMSET', key, *items)
+ return self.execute_command('HMSET', name, *items)
def hmget(self, name, keys):
"Returns a list of values ordered identically to ``keys``"
@@ -1036,6 +1036,25 @@ class Redis(threading.local):
# channels
+ def psubscribe(self, patterns):
+ "Subscribe to all channels matching any pattern in ``patterns``"
+ if isinstance(patterns, basestring):
+ patterns = [patterns]
+ response = self.execute_command('PSUBSCRIBE', *patterns)
+ # this is *after* the SUBSCRIBE in order to allow for lazy and broken
+ # connections that need to issue AUTH and SELECT commands
+ self.subscribed = True
+ return response
+
+ def punsubscribe(self, patterns=[]):
+ """
+ Unsubscribe from any channel matching any pattern in ``patterns``.
+ If empty, unsubscribe from all channels.
+ """
+ if isinstance(patterns, basestring):
+ patterns = [patterns]
+ return self.execute_command('PUNSUBSCRIBE', *patterns)
+
def subscribe(self, channels):
"Subscribe to ``channels``, waiting for messages to be published"
if isinstance(channels, basestring):
@@ -1047,7 +1066,10 @@ class Redis(threading.local):
return response
def unsubscribe(self, channels=[]):
- "Unsubscribe to ``channels``. If empty, unsubscribe from all channels"
+ """
+ Unsubscribe from ``channels``. If empty, unsubscribe
+ from all channels
+ """
if isinstance(channels, basestring):
channels = [channels]
return self.execute_command('UNSUBSCRIBE', *channels)