Change Cache Middleware Via Setting?

56 views
Skip to first unread message

Michael Orr

unread,
Dec 10, 2013, 2:55:08 PM12/10/13
to django-d...@googlegroups.com
So I'm writing a library that allows users to interact with memcache in more interesting ways. In order to utilize this library, extra kwargs were added to `get()` and `set()` that are expected to exist when interacting with the cache. In order to get django to use and understand this additional functionality, I had to write a custom cache middleware. No big deal so far. My only gotcha is that this will only work for whole-site caching when specifying the my custom cache middleware class in `MIDDLEWARE_CLASSES`. It doesn't, however, work for `@cache_page` which uses `decorator_from_middleware_with_args(CacheMiddleware)`. It directly references `CacheMiddleware` which is the provided cache middleware from in django core. I would love to write a patch that allows the user to specify an alternate `CACHE_MIDDLEWARE` setting that is a string representation of a class and is then referenced in "utils/decorators.py" with the default being the provided `CacheMiddleware`.
I was hoping for some feedback before submitting the patch. Thoughts?
Reply all
Reply to author
Forward
0 new messages