How to use 2 different cache backends in Django?
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': 'c:/foo/bar',
},
'inmem': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
from django.core.cache import get_cache, cache
inmem_cache = get_cache('inmem')
default_cache = get_cache('default')
# default_cache == cache
Since Django 1.9, get_cache
is deprecated. Do the following to address keys from 'inmem' (addition to answer by Romans):
from django.core.cache import caches
caches['inmem'].get(key)