# HG changeset patch
# User Simon Law <simon@akoha.org>
# Date 1207702167 14400
# Node ID ee193c85cda9c596152a230286b1052c7399b01f
# Parent 8f35d9182ce1fccc95b09f6bfedd0ff7a9c20f34
#2107 - memcached cache behaves the same as other caches when timeout=0
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
a
|
b
|
class CacheClass(BaseCache):
|
17 | 17 | self._cache = memcache.Client(server.split(';')) |
18 | 18 | |
19 | 19 | def add(self, key, value, timeout=0): |
20 | | self._cache.add(key.encode('ascii', 'ignore'), value, timeout or self.default_timeout) |
| 20 | timeout = timeout or self.default_timeout |
| 21 | if timeout: |
| 22 | self._cache.add(key.encode('ascii', 'ignore'), value, timeout) |
21 | 23 | |
22 | 24 | def get(self, key, default=None): |
23 | 25 | val = self._cache.get(smart_str(key)) |
… |
… |
class CacheClass(BaseCache):
|
32 | 34 | def set(self, key, value, timeout=0): |
33 | 35 | if isinstance(value, unicode): |
34 | 36 | value = value.encode('utf-8') |
35 | | self._cache.set(smart_str(key), value, timeout or self.default_timeout) |
| 37 | timeout = timeout or self.default_timeout |
| 38 | if timeout: |
| 39 | self._cache.set(smart_str(key), value, timeout) |
36 | 40 | |
37 | 41 | def delete(self, key): |
38 | 42 | self._cache.delete(smart_str(key)) |