Monkey patch django.util.cache function

2019-09-07 12:26发布

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.

0条回答
登录 后发表回答