Monkey patch django.util.cache function

匆匆过客 提交于 2019-12-12 04:14:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!