Interesting problem. Turns out you need to look very closely at the documentation and notice that KEY_PREFIX is a subkey in the CACHES[<cache>
]. You need to define it like this.
CACHE_MIDDLEWARE_KEY_PREFIX = 'staging'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'production_cache_server:11211',
'KEY_PREFIX': CACHE_MIDDLEWARE_KEY_PREFIX,
}
}
This is also the way to define a KEY_FUNCTION
as well. I verified this will also work.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'production.jxycyn.cfg.usw1.cache.amazonaws.com:11211',
'KEY_FUNCTION': 'apps.core.cache_utils.make_key',
}
}