Memoize Expensive Functions
Cache function results by arguments.
Beyond Whole Views
Sometimes only one slow helper is the problem, not the whole page. Memoization caches a function result keyed by its arguments.
The memoize Decorator
You wrap a function with @cache.memoize(). Same arguments return the stored result instead of recomputing it. 💡
@cache.memoize()
def heavy(n):
return slow_calc(n)All lessons in this course
- Set Up Flask-Caching
- Cache a View with cached
- Memoize Expensive Functions
- Invalidate and Expire Cache Entries