diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-06-16 16:20:05 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-06-16 16:20:05 -0700 |
commit | dffc6f97ce5cce454c07006e03b70c4cf41348bd (patch) | |
tree | a99b875873b35ae0227b288eb15c2a3c61759b36 /redis/connection.py | |
parent | 1acc67ac789b9a4cc8f480fbf328ae4c711e29a0 (diff) | |
download | redis-py-dffc6f97ce5cce454c07006e03b70c4cf41348bd.tar.gz |
pack multiple commands in a pipeline into larger strings.
fixes #495
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-x | redis/connection.py | 16 |
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>" |