summaryrefslogtreecommitdiff
path: root/django/core/cache
diff options
context:
space:
mode:
authorMalcolm Box <malcolm@tellybug.com>2014-04-23 12:06:23 +0100
committerClaude Paroz <claude@2xlibre.net>2014-04-23 14:49:46 +0200
commitaf5f688392b7fc110d06660ff91f79c742ae751d (patch)
treecd65b62872d9bd799256c397a84530ffe82612ba /django/core/cache
parent2ffa6ca73a1ecc16cdfa8c03402a17a5c2e2f8cb (diff)
Fixed #22495 -- Locmem cache.add() failed with infinite timeouts
cache.add() incorrectly succeeded when there was an existing key with an infinite (None) timeout.
Diffstat (limited to 'django/core/cache')
-rw-r--r--django/core/cache/backends/locmem.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/core/cache/backends/locmem.py b/django/core/cache/backends/locmem.py
index 73b02a55b3..aba8b61a4d 100644
--- a/django/core/cache/backends/locmem.py
+++ b/django/core/cache/backends/locmem.py
@@ -29,8 +29,8 @@ class LocMemCache(BaseCache):
self.validate_key(key)
pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
with self._lock.writer():
- exp = self._expire_info.get(key)
- if exp is None or exp <= time.time():
+ exp = self._expire_info.get(key, 0)
+ if exp is not None and exp <= time.time():
self._set(key, pickled, timeout)
return True
return False