def cas(self, key, value, etag, time=None): '''Stores the value under key, but only if the given cas token is present for the existing value Returns success''' entry = self.__store.get(key) if entry and (entry.expired or entry.etag != etag): logger.debug("CAS '%s' MISMATCH", key) raise pylibmc.NotFound() token = self.__flags.pop(key, None) if token: if token[1]: token[1](self, key) logger.debug("CAS '%s' MISMATCH", key) raise pylibmc.NotFound() logger.debug("CAS '%s' = %s, for %s", str(key), str(value), str(time)) self.__store[key] = MockEntry(key, value, time, self) return True
def fake_incr_multi(keys, delta=1): if evicted: for key in keys: del self.cache[key] raise pylibmc.NotFound() return real_incr(key)
def fake_incr(key, delta=1): if evicted: del self.cache[key] raise pylibmc.NotFound() return real_incr(key)