Jar cache, delete_memoized equivalent to clear

I am using Flask cache in my python API.

I am currently using the @app.cache.memoize(cache_memoize_value) decorator and I clear it by calling app.cache.delete_memoized(view)

The problem is that with memoize it will be cached for representations n , and not for a certain amount of time. If I want to specify a timeout for the cache, I need to use the @app.cache.cached(timeout=300) decorator and clear it with app.cache.clear() . However, this clear-cut method will clear everything, not just a specific view.

How can I clear a specific view when using a cached decorator?

+5
source share
1 answer

This is actually pretty easy, and I should have tried it before. As with a cached decorator, you can specify a value in a memoized decorator. But instead: @app.cache.memoize(cache_memoize_value)

You need to do this @app.cache.memoize(timeout=cache_memoize_value)

+2
source

Source: https://habr.com/ru/post/1245628/


All Articles