Debian Codegraph @

src/flask_caching/signals.py

raw
1 """
2 flask_caching.signals
3 ~~~~~~~~~~~~~~~~~~~~~
4
5 The signals for Flask-Caching.
6
7 :copyright: (c) 2026 by Peter Justin
8 :license: BSD, see LICENSE for more details.
9 """
10
11 from blinker import Namespace
12
13 _signals = Namespace()
14
15 #: Sent when a view decorated with :meth:`~Cache.cached` is served from the
16 #: cache. It is passed ``cache``, the :class:`Cache` instance, ``cache_key``,
17 #: the key the response was found under, and ``args`` and ``kwargs``, the
18 #: arguments the view was called with.
19 cache_view_hit = _signals.signal("cache-view-hit")
20
21 #: Sent when a view decorated with :meth:`~Cache.cached` is not found in the
22 #: cache and has to be called. It is passed the same arguments as
23 #: :data:`cache_view_hit`.
24 cache_view_miss = _signals.signal("cache-view-miss")
25
26 #: Sent when a function decorated with :meth:`~Cache.memoize` is served from
27 #: the cache. In addition to the arguments passed to :data:`cache_view_hit`,
28 #: it is passed ``f``, the undecorated function.
29 cache_memoize_hit = _signals.signal("cache-memoize-hit")
30
31 #: Sent when a function decorated with :meth:`~Cache.memoize` is not found in
32 #: the cache and has to be called. It is passed the same arguments as
33 #: :data:`cache_memoize_hit`.
34 cache_memoize_miss = _signals.signal("cache-memoize-miss")