diff -r 4e09c07db18b django/core/cache/__init__.py
a
|
b
|
See docs/cache.txt for information on th
|
17 | 17 | |
18 | 18 | from cgi import parse_qsl |
19 | 19 | from django.conf import settings |
| 20 | from django.core import signals |
20 | 21 | from django.core.cache.backends.base import InvalidCacheBackendError |
| 22 | from django.dispatch import dispatcher |
21 | 23 | |
22 | 24 | BACKENDS = { |
23 | 25 | # name for use in settings file --> name of module in "backends" directory |
… |
… |
def get_cache(backend_uri):
|
52 | 54 | return cache_class(host, params) |
53 | 55 | |
54 | 56 | cache = get_cache(settings.CACHE_BACKEND) |
| 57 | |
| 58 | # Some caches -- memcached in particular -- need to do cleanup at the end of a |
| 59 | # request cycle. If the cache provides a close() method, wire it up here. |
| 60 | if hasattr(cache, "close"): |
| 61 | dispatcher.connect(cache.close, signal=signals.request_finished) |
diff -r 4e09c07db18b django/core/cache/backends/memcached.py
a
|
b
|
class CacheClass(BaseCache):
|
36 | 36 | |
37 | 37 | def get_many(self, keys): |
38 | 38 | return self._cache.get_multi(map(smart_str,keys)) |
| 39 | |
| 40 | def close(self): |
| 41 | self._cache.disconnect_all() |