Ticket #7398: ease-custom-cache-backends-with-documentation.diff
File ease-custom-cache-backends-with-documentation.diff, 2.2 KB (added by , 16 years ago) |
---|
-
django/core/cache/__init__.py
20 20 from django.core.cache.backends.base import InvalidCacheBackendError 21 21 22 22 BACKENDS = { 23 # name for use in settings file --> name of module in "backends" directory24 'memcached': ' memcached',25 'locmem': ' locmem',26 'file': ' filebased',27 'db': 'd b',28 'dummy': 'd ummy',23 # name for use in settings file --> path to the backend module 24 'memcached': 'django.core.cache.backends.memcached', 25 'locmem': 'django.core.cache.backends.locmem', 26 'file': 'django.core.cache.backends.filebased', 27 'db': 'django.core.cache.backends.db', 28 'dummy': 'django.core.cache.backends.dummy', 29 29 } 30 30 31 if hasattr(settings, "CACHE_BACKEND_MODULES"): 32 BACKENDS.update(settings.CACHE_BACKEND_MODULES) 33 31 34 DEPRECATED_BACKENDS = { 32 35 # deprecated backend --> replacement module 33 36 'simple': 'locmem', … … 57 60 if host.endswith('/'): 58 61 host = host[:-1] 59 62 60 cache_class = getattr(__import__( 'django.core.cache.backends.%s' %BACKENDS[scheme], {}, {}, ['']), 'CacheClass')63 cache_class = getattr(__import__(BACKENDS[scheme], {}, {}, ['']), 'CacheClass') 61 64 return cache_class(host, params) 62 65 63 66 cache = get_cache(settings.CACHE_BACKEND) -
docs/settings.txt
256 256 257 257 The cache backend to use. See the `cache docs`_. 258 258 259 CACHE_BACKEND_MODULES 260 --------------------- 261 262 **New in Django development version** 263 264 Default: Not defined. 265 266 A dictionary of cache backend import paths, keyed by a string 267 identifier for use in ``CACHE_BACKEND``. These are added to the 268 build-in backends. For example, to define a 'penandpaper' backend, 269 use:: 270 271 CACHE_BACKEND_MODULES = { 'penandpaper' : 'path.to.penandpaper_backend' } 272 273 Reference this module in CACHE_BACKEND as ``'penandpaper://'``. Note 274 that build-in backends can be replaced by overwriting them in this 275 variable. 276 259 277 CACHE_MIDDLEWARE_KEY_PREFIX 260 278 --------------------------- 261 279