问题
I'm having issues figuring out how to monkey patch a few functions in django.util.cache
. I don't want to write my own caching middleware, I just want keys that are a little easier to swallow. The make_key
property on cache backends doesn't cut it either for my use case.
I've tried adding
from django.utils.cache import _generate_cache_key, _generate_cache_header_key
from spark_core import middleware
_generate_cache_key = middleware._generate_cache_key
_generate_cache_header_key = middleware._generate_cache_header_key
at the bottom of my settings.py
file, but didn't have any luck with that. I'm using the per-site cache.
来源:https://stackoverflow.com/questions/25366405/monkey-patch-django-util-cache-function