diff options
| author | Mike Grouchy <mgrouchy@gmail.com> | 2012-07-18 08:00:31 -0400 |
|---|---|---|
| committer | Mike Grouchy <mgrouchy@gmail.com> | 2012-07-18 14:16:55 -0400 |
| commit | a2e927b7ed25bd319f866c55b18cd214a149d859 (patch) | |
| tree | a7b170ceae5040f804d5b0aadeebf74ee4fec923 /django/core/cache/backends/base.py | |
| parent | 8184aff2b0a3fbe6759163c0289f640a393a3e99 (diff) | |
BaseCache now has a no-op close method as per ticket #18582
Also removed the hasattr check when firing request_finished signal for
caches with a 'close' method. Should be safe to call `cache.close`
everywhere now
Diffstat (limited to 'django/core/cache/backends/base.py')
| -rw-r--r-- | django/core/cache/backends/base.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index f7573b2e31..e28ebbe2cf 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -6,15 +6,18 @@ from django.core.exceptions import ImproperlyConfigured, DjangoRuntimeWarning from django.utils.encoding import smart_str from django.utils.importlib import import_module + class InvalidCacheBackendError(ImproperlyConfigured): pass + class CacheKeyWarning(DjangoRuntimeWarning): pass # Memcached does not accept keys longer than this. MEMCACHE_MAX_KEY_LENGTH = 250 + def default_key_func(key, key_prefix, version): """ Default function to generate keys. @@ -25,6 +28,7 @@ def default_key_func(key, key_prefix, version): """ return ':'.join([key_prefix, str(version), smart_str(key)]) + def get_key_func(key_func): """ Function to decide which key function to use. @@ -40,6 +44,7 @@ def get_key_func(key_func): return getattr(key_func_module, key_func_name) return default_key_func + class BaseCache(object): def __init__(self, params): timeout = params.get('timeout', params.get('TIMEOUT', 300)) @@ -221,3 +226,7 @@ class BaseCache(object): the new version. """ return self.incr_version(key, -delta, version) + + def close(self, **kwargs): + """Close the cache connection""" + pass |
