summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2014-06-16 16:20:05 -0700
committerAndy McCurdy <andy@andymccurdy.com>2014-06-16 16:20:05 -0700
commitdffc6f97ce5cce454c07006e03b70c4cf41348bd (patch)
treea99b875873b35ae0227b288eb15c2a3c61759b36 /redis/connection.py
parent1acc67ac789b9a4cc8f480fbf328ae4c711e29a0 (diff)
downloadredis-py-dffc6f97ce5cce454c07006e03b70c4cf41348bd.tar.gz
pack multiple commands in a pipeline into larger strings.
fixes #495
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-xredis/connection.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 40966e3..2123b33 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -598,6 +598,22 @@ class Connection(object):
output.append(buff)
return output
+ def pack_commands(self, commands):
+ "Pack multiple commands into the Redis protocol"
+ pieces = []
+ buff = ''
+
+ for cmd in commands:
+ packed = self.pack_command(*cmd)[0]
+ buff = SYM_EMPTY.join((buff, packed))
+ if len(buff) > 6000:
+ pieces.append(buff)
+ buff = ''
+
+ if buff:
+ pieces.append(buff)
+ return pieces
+
class SSLConnection(Connection):
description_format = "SSLConnection<host=%(host)s,port=%(port)s,db=%(db)s>"