Yes something like this. I would comment on implementation details, but at
this point I want to know if people would be content to add this sort of
functionality to core.
Of course, there bound to be a library that essentially does this, however
seeing it as such a common utility I think it woul
You’d mean something like this (for inspiration)?
https://gist.github.com/vdboor/80e5ffa148fb30d33d938593855af9ac
This would give the simplicity of using a @cache_results decorator,
while allowing to bypass or refresh the cache when needed.
I’m not sure but likely there are some packages that ha
I would like to see more opinions on this, I am using this type of utility
in almost every project I make and it seems to me it would a decent utility
function.
26 Ağustos 2022 Cuma tarihinde saat 14:45:13 UTC+3 itibarıyla suayip
uzulmez şunları yazdı:
> It doesn't necessarily have to be a Que
It doesn't necessarily have to be a QuerySet; any function or method that
takes some processing time could be decorated (e.g., an external call to an
API). My aim is to reduce this code:
def do_some_processing():
cache_key = "key"
if cached_value := cache.get(cache_key):
return
I'm not sure I quite understand your proposal. Are you suggesting a
decorator that caches the results of every queryset that is resolved within
the decorated function?
If so, I'm not sure how useful it would be. First, if a single query is
problematic, there’s normally a way to optimize it within
Usually, I need to construct a simple cache pipeline to optimize database
access using low-level cache API (django.core.cache).
I think we could use a decorator as such to ease this process:
cached_context(key, *, timeout, cache)
I know higher-level utilities exist such as cache_page, however I