Default django cache keys generator:
def make_key(key, key_prefix, version):
return ':'.join([key_prefix, str(version), key])
I want to change with:
in settings.py
def make_key(key, key_prefix, version):
return key
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'KEY_FUNCTION' : 'settings.make_key',
}
}
but django generate keys with old native function (prefix-version-key) how to change it?
Try:
I know that in documentation is “string containing a dotted path” but I see in the Django source code that you can also pass callable object (eg. function).
If you really need to pass it as a string, you should move this function to another module and set
yourproject.module.make_keyasKEY_FUNCTION.