def set(self, key, value, time=0, min_compress_len=0): """Sets the value for a key.""" timeout = 0 if time != 0: timeout = utils.utcnow_ts() + time self.cache[key] = (timeout, value) return True
def get(self, key): """Retrieves the value for a key or None.""" (timeout, value) = self.cache.get(key, (0, None)) if timeout == 0 or utils.utcnow_ts() < timeout: return value return None