67 | | if not settings.CACHES: |
68 | | legacy_backend = getattr(settings, 'CACHE_BACKEND', None) |
69 | | if legacy_backend: |
70 | | import warnings |
71 | | warnings.warn( |
72 | | "settings.CACHE_* is deprecated; use settings.CACHES instead.", |
73 | | DeprecationWarning |
74 | | ) |
75 | | else: |
76 | | # The default cache setting is put here so that we |
77 | | # can differentiate between a user who has provided |
78 | | # an explicit CACHE_BACKEND of locmem://, and the |
79 | | # default value. When the deprecation cycle has completed, |
80 | | # the default can be restored to global_settings.py |
81 | | settings.CACHE_BACKEND = 'locmem://' |
82 | | |
83 | | # Mapping for new-style cache backend api |
84 | | backend_classes = { |
85 | | 'memcached': 'memcached.CacheClass', |
86 | | 'locmem': 'locmem.LocMemCache', |
87 | | 'file': 'filebased.FileBasedCache', |
88 | | 'db': 'db.DatabaseCache', |
89 | | 'dummy': 'dummy.DummyCache', |
90 | | } |
91 | | engine, host, params = parse_backend_uri(settings.CACHE_BACKEND) |
92 | | if engine in backend_classes: |
93 | | engine = 'django.core.cache.backends.%s' % backend_classes[engine] |
94 | | else: |
95 | | engine = '%s.CacheClass' % engine |
96 | | defaults = { |
97 | | 'BACKEND': engine, |
98 | | 'LOCATION': host, |
99 | | } |
100 | | defaults.update(params) |
101 | | settings.CACHES[DEFAULT_CACHE_ALIAS] = defaults |
102 | | |