Delete specific cache in Flask-Cache or Flask-Caching

  • For cache.cached(), use cache.delete() to delete specific cache, pass the cache key (default to view/<request.path>).
  • For cache.memoize(), use cache.delete_memoized() to delete specific cache, pass the cache key (default to function name with or without args).
  • Use cache.clear() to delete all the cache data.

It's in fact pretty easy and I should have tried this before. Like for the cached decorator, you can specify a value in the memoized decorator. But instead of doing this: @app.cache.memoize(cache_memoize_value)

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