Ticket #7398: ease-custom-cache-backends.diff

File ease-custom-cache-backends.diff, 1.4 KB (added by lau@…, 16 years ago)

Ease custom cache backends

  • django/core/cache/__init__.py

     
    2020from django.core.cache.backends.base import InvalidCacheBackendError
    2121
    2222BACKENDS = {
    23     # name for use in settings file --> name of module in "backends" directory
    24     'memcached': 'memcached',
    25     'locmem': 'locmem',
    26     'file': 'filebased',
    27     'db': 'db',
    28     'dummy': 'dummy',
     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',
    2929}
    3030
     31if hasattr(settings, "CACHE_BACKEND_MODULES"):
     32    BACKENDS.update(settings.CACHE_BACKEND_MODULES)
     33
    3134DEPRECATED_BACKENDS = {
    3235    # deprecated backend --> replacement module
    3336    'simple': 'locmem',
     
    5760    if host.endswith('/'):
    5861        host = host[:-1]
    5962
    60     cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']), 'CacheClass')
     63    cache_class = getattr(__import__(BACKENDS[scheme], {}, {}, ['']), 'CacheClass')
    6164    return cache_class(host, params)
    6265
    6366cache = get_cache(settings.CACHE_BACKEND)
Back to Top