diff -r 4e09c07db18b django/core/cache/__init__.py
--- a/django/core/cache/__init__.py	Fri Aug 10 11:12:16 2007 -0500
+++ b/django/core/cache/__init__.py	Fri Aug 10 11:31:35 2007 -0500
@@ -17,7 +17,9 @@ See docs/cache.txt for information on th
 
 from cgi import parse_qsl
 from django.conf import settings
+from django.core import signals
 from django.core.cache.backends.base import InvalidCacheBackendError
+from django.dispatch import dispatcher
 
 BACKENDS = {
     # name for use in settings file --> name of module in "backends" directory
@@ -52,3 +54,8 @@ def get_cache(backend_uri):
     return cache_class(host, params)
 
 cache = get_cache(settings.CACHE_BACKEND)
+
+# Some caches -- memcached in particular -- need to do cleanup at the end of a
+# request cycle. If the cache provides a close() method, wire it up here.
+if hasattr(cache, "close"):
+    dispatcher.connect(cache.close, signal=signals.request_finished)
diff -r 4e09c07db18b django/core/cache/backends/memcached.py
--- a/django/core/cache/backends/memcached.py	Fri Aug 10 11:12:16 2007 -0500
+++ b/django/core/cache/backends/memcached.py	Fri Aug 10 11:31:35 2007 -0500
@@ -36,3 +36,6 @@ class CacheClass(BaseCache):
 
     def get_many(self, keys):
         return self._cache.get_multi(map(smart_str,keys))
+    
+    def close(self):
+        self._cache.disconnect_all()
