Permalink
Browse files

Fixed set_multi serialization performance

  • Loading branch information...
1 parent f74f94e commit 5e43ab376f65e95a2d303fcb1e1f2910ee5c6d8b Marshall Quander committed May 10, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 memcache.py
View
7 memcache.py
@@ -589,7 +589,8 @@ def set_multi(self, mapping, time=0, key_prefix='', min_compress_len=0):
dead_servers = []
for server in server_keys.keys():
- bigcmd = bytes()
+ bigcmd = bytearray()
+ write = bigcmd.extend
try:
newline = "\r\n".encode('utf-8')
for key in server_keys[server]: # These are mangled keys
@@ -599,8 +600,8 @@ def set_multi(self, mapping, time=0, key_prefix='', min_compress_len=0):
cmd += store_info[2].encode('utf-8')
else:
cmd += store_info[2]
- bigcmd += cmd + newline
- server.send_cmds(bigcmd)
+ write(cmd + newline)
+ server.send_cmds(bytes(bigcmd))
except socket.error as msg:
if type(msg) is tuple: msg = msg[1]
server.mark_dead(msg)

0 comments on commit 5e43ab3

Please sign in to comment.