API¶
This section contains the API documentation of the Flask-Caching extension and lists the backends which are supported out of the box via cachelib. The Configuration section explains how the backends can be used.
Cache API¶
Signals¶
The following signals are supported:
- cache_view_hit¶
Sent when a view decorated with
cached()is served from the cache. It is passedcache, theCacheinstance,cache_key, the key the response was found under, andargsandkwargs, the arguments the view was called with.
- cache_view_miss¶
Sent when a view decorated with
cached()is not found in the cache and has to be called. It is passed the same arguments ascache_view_hit.
- cache_memoize_hit¶
Sent when a function decorated with
memoize()is served from the cache. In addition to the arguments passed tocache_view_hit, it is passedf, the undecorated function.
- cache_memoize_miss¶
Sent when a function decorated with
memoize()is not found in the cache and has to be called. It is passed the same arguments ascache_memoize_hit.
By default, signals are disabled. To enable sending signals set
CACHE_ENABLE_SIGNALS to True.
See the Flask documentation on signals for information on how to use these signals in your code.