Permalink
Browse files

Merge pull request #3 from mquander/patch-2

Fixed set_multi serialization performance
  • Loading branch information...
2 parents f74f94e + 5e43ab3 commit ab1d47b7e94a8a59ddc888f22bd9e0e4ec10613d @eguven committed May 11, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 memcache.py
View
@@ -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 ab1d47b

Please sign in to comment.