I have a Django app set up to use multiple caches (I hope). Is there a way to set the session to use a specific cache, or is it stuck on 'default'?
Here's what i have now:
CACHES = {
'default': {
'BACKEND': 'util.backends.SmartMemcachedCache',
'LOCATION': '127.0.0.1:11211',
'TIMEOUT': 300,
'ANONYMOUS_ONLY': True
},
'some_other_cache': {
'BACKEND': 'util.backends.SmartMemcachedCache',
'LOCATION': '127.0.0.1:11211',
'TIMEOUT': 300,
'ANONYMOUS_ONLY': True,
'PREFIX': 'something'
},
}
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
The
cached_db
andcache
backends don't support it, but it's easy to create your own:No need for a
cached_db
backend since Redis is persistent anyway :)When using Memcached and
cached_db
, its a bit more complex because of how thatSessionStore
is implemented. We just replace it completely: