Ticket #16358: memcached.py.patch

File memcached.py.patch, 640 bytes (added by ccrisan, 13 years ago)

patch for memcached.py that makes the backend clear a key if unable to set it

  • memcached.py

    old new  
    6262
    6363    def set(self, key, value, timeout=0, version=None):
    6464        key = self.make_key(key, version=version)
    65         self._cache.set(key, value, self._get_memcache_timeout(timeout))
     65        if not self._cache.set(key, value, self._get_memcache_timeout(timeout)):
     66            self._cache.delete(key) # make sure the key doesn't keep its old value in case of failure to set (memcached's 1MB limit)
    6667
    6768    def delete(self, key, version=None):
    6869        key = self.make_key(key, version=version)
Back to Top