Commit 4e30884a authored by Tomi Suomela's avatar Tomi Suomela

Fix touch() a bit

parent bf62839f
...@@ -366,11 +366,15 @@ class BaseRedisCache(BaseCache): ...@@ -366,11 +366,15 @@ class BaseRedisCache(BaseCache):
@get_client(write=True) @get_client(write=True)
def touch(self, client, key, timeout=DEFAULT_TIMEOUT, stale_cache_timeout=None): def touch(self, client, key, timeout=DEFAULT_TIMEOUT, stale_cache_timeout=None):
"""Reset the timeout of a key to `timeout` seconds.""" """Reset the timeout of a key to `timeout` seconds."""
key_timeout = ( fresh_key = "__fresh__" + key
None if stale_cache_timeout is None else timeout + stale_cache_timeout key_timeout = timeout
) if client.exists(fresh_key):
client.expire("__fresh__" + key, key_timeout) key_timeout = (
return client.expire(key, timeout) None if stale_cache_timeout is None else timeout + stale_cache_timeout
)
client.expire("__fresh__" + key, timeout)
return client.expire(key, key_timeout)
##################### #####################
# Extra api methods # # Extra api methods #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment