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 the database - for example, a materialized view allows you to “cache” query results and recompute them in the background. Second, QuerySets are lazy, so it could be surprising to decorate a function that returns a QuerySet that is not yet resolved. On Wed, Aug 24, 2022 at 3:49 PM suayip uzulmez <suayip....@gmail.com> wrote: > 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 think > the decorator above provides more granularity over what to cache. For > example, I usually need such decorator in model methods where I do some > database aggregation operations based on the instance. > > What do you think? > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/facbcfa8-2404-4dc6-b56d-eb0f25ba491cn%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/facbcfa8-2404-4dc6-b56d-eb0f25ba491cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM3jh_tHOLfxggk68114kSS3qk3i0vBsd-kvqcp1WXCr7Q%40mail.gmail.com.