summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/core/cache/__init__.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
index b97c7469bb..346deae916 100644
--- a/django/core/cache/__init__.py
+++ b/django/core/cache/__init__.py
@@ -176,12 +176,13 @@ def get_cache(backend, **kwargs):
except (AttributeError, ImportError), e:
raise InvalidCacheBackendError(
"Could not find backend '%s': %s" % (backend, e))
- return backend_cls(location, params)
+ cache = backend_cls(location, params)
+ # Some caches -- python-memcached in particular -- need to do a cleanup at the
+ # end of a request cycle. If the cache provides a close() method, wire it up
+ # here.
+ if hasattr(cache, 'close'):
+ signals.request_finished.connect(cache.close)
+ return cache
cache = get_cache(DEFAULT_CACHE_ALIAS)
-# Some caches -- python-memcached in particular -- need to do a cleanup at the
-# end of a request cycle. If the cache provides a close() method, wire it up
-# here.
-if hasattr(cache, 'close'):
- signals.request_finished.connect(cache.close)