diff options
author | Sean Reifschneider <jafo@tummy.com> | 2008-05-31 03:56:10 -0600 |
---|---|---|
committer | Sean Reifschneider <jafo@tummy.com> | 2008-05-31 03:56:10 -0600 |
commit | 9edc0a0b5a35fedff04770f3a8e74b479155e55e (patch) | |
tree | 54daacc2d57a7289eba19ec2cdf3621eaa851f3b | |
parent | 88a4a25d1f1f5b18f3054d2146c90327a0fd9d97 (diff) | |
download | python-memcached-9edc0a0b5a35fedff04770f3a8e74b479155e55e.tar.gz |
* Patches from Steve Schwarz for set_multi() to return the full set of
keys if all servers are down. Previously would not report any keys.
* Fix from Steve Schwarz delete_multi() argument "seconds" not being
correctly handled. Changed it to "time" to match all other calls.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | memcache.py | 28 |
2 files changed, 30 insertions, 4 deletions
@@ -12,6 +12,12 @@ Sat, 31 May 2008 02:09:17 -0600 Sean Reifschneider <jafo@tummy.com> mark_dead() to make them dereference tuples, reducing timeout on sockets to 3 seconds, settable via setting Host._SOCKET_TIMEOUT. + * Patches from Steve Schwarz for set_multi() to return the full set of + keys if all servers are down. Previously would not report any keys. + + * Fix from Steve Schwarz delete_multi() argument "seconds" not being + correctly handled. Changed it to "time" to match all other calls. + Tue, 29 Apr 2008 21:03:53 -0600 Sean Reifschneider <jafo@tummy.com> * Version 1.41 diff --git a/memcache.py b/memcache.py index 5515b20..8e0dd89 100644 --- a/memcache.py +++ b/memcache.py @@ -244,7 +244,7 @@ class Client(local): for s in self.servers: s.close_socket() - def delete_multi(self, keys, seconds=0, key_prefix=''): + def delete_multi(self, keys, time=0, key_prefix=''): ''' Delete multiple keys in the memcache doing just one query. @@ -262,7 +262,7 @@ class Client(local): the next one. @param keys: An iterable of keys to clear - @param seconds: number of seconds any subsequent set / update commands should fail. Defaults to 0 for no delay. + @param time: number of seconds any subsequent set / update commands should fail. Defaults to 0 for no delay. @param key_prefix: Optional string to prepend to each key when sending to memcache. See docs for L{get_multi} and L{set_multi}. @@ -284,7 +284,7 @@ class Client(local): write = bigcmd.append if time != None: for key in server_keys[server]: # These are mangled keys - write("delete %s %d\r\n" % (key, seconds)) + write("delete %s %d\r\n" % (key, time)) else: for key in server_keys[server]: # These are mangled keys write("delete %s\r\n" % key) @@ -315,7 +315,7 @@ class Client(local): '''Deletes a key from the memcache. @return: Nonzero on success. - @param seconds: number of seconds any subsequent set / update commands should fail. Defaults to 0 for no delay. + @param time: number of seconds any subsequent set / update commands should fail. Defaults to 0 for no delay. @rtype: int ''' check_key(key) @@ -567,6 +567,9 @@ class Client(local): for server in dead_servers: del server_keys[server] + # short-circuit if there are no servers, just return all keys + if not server_keys: return(mapping.keys()) + notstored = [] # original keys. for server, keys in server_keys.iteritems(): try: @@ -1053,5 +1056,22 @@ if __name__ == "__main__": else: print "FAIL" + print "Testing set_multi() with no memcacheds running", + mc.disconnect_all() + errors = mc.set_multi({'keyhere' : 'a', 'keythere' : 'b'}) + if errors != []: + print "FAIL" + else: + print "OK" + + print "Testing delete_multi() with no memcacheds running", + mc.disconnect_all() + ret = mc.delete_multi({'keyhere' : 'a', 'keythere' : 'b'}) + if ret != 1: + print "FAIL" + else: + print "OK" + + # vim: ts=4 sw=4 et : |