Open robrap opened 6 years ago
There are currently two ways that you achieve the effect of request-scoping all in-memory caching:
session_function
which takes no arguments and returns a short string that varies on request or threading.local()
or whatever else you use to define a "session" or single conceptual execution period. For an example of how we've done that in another project, you can refer to: https://github.com/dimagi/commcare-hq/blob/08dde6f16afaf3aed1d1ee500986e3b06aab6bc3/corehq/util/quickcache.py#L19-L47request
or threading.local()
. If you name this cache 'locmem'
in your settings.py
, quickcache will use it.It occurs to me that I have not documented that get_django_quickcache
uses your Django caches named 'default'
(for shared cache) and 'locmem'
(for in-memory cache), and that these should be something you can specify when calling get_django_quickcache
. I've opened an issue about this https://github.com/dimagi/quickcache/issues/13
Thanks for your response Danny. I'll let you know if I have any questions, but hopefully this should cover it.
Hello.
I was implementing my own version of a TieredCache in Django when a colleague pointed me to this caching solution. I like it, but the local cache I want is a Request Cache, rather than the Timed Memoized Cache. I also heard you may already have a Request Cache version available?
Thank you.
Robert