Commit 559c01c0 authored by Tomaž Muraus's avatar Tomaž Muraus

Fixed a default timeout problem - if no timeout was specified the default…

Fixed a default timeout problem - if no timeout was specified the default timeout specified in settings was not used.

Now, you have three choices:
1. no timeout is specified - the default timeout is used
2. timeout is specified and it's not False - the specified value is used
3. timeout is specified as False - no timeout is set for this key and it does not expire
parent c56924a1
...@@ -59,7 +59,7 @@ class CacheClass(BaseCache): ...@@ -59,7 +59,7 @@ class CacheClass(BaseCache):
else: else:
return value return value
def set(self, key, value, timeout=0): def set(self, key, value, timeout=None):
"Persist a value to the cache, and set an optional expiration time." "Persist a value to the cache, and set an optional expiration time."
key = self._prepare_key(key) key = self._prepare_key(key)
...@@ -72,7 +72,8 @@ class CacheClass(BaseCache): ...@@ -72,7 +72,8 @@ class CacheClass(BaseCache):
result = self._cache.set(key, value) result = self._cache.set(key, value)
# set content expiration, if necessary # set content expiration, if necessary
if timeout > 0: if timeout is None or timeout is not False:
timeout = timeout or self.default_timeout
self._cache.expire(key, timeout) self._cache.expire(key, timeout)
if result == "OK": if result == "OK":
......
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