Debian Codegraph @

docs/api.rst

raw
1 API
2 ===
3
4 This section contains the API documentation of the Flask-Caching extension and
5 lists the backends which are supported out of the box via cachelib.
6 The :ref:`Configuration <configuring-flask-caching>` section explains
7 how the backends can be used.
8
9
10 .. currentmodule:: flask_caching
11
12
13 Cache API
14 ---------
15 .. module:: flask_caching
16 .. autoclass:: Cache
17 :members: cache, init_app, get, set, add, delete, get_many, set_many,
18 delete_many, get_dict, unlink, has, clear, cached, delete_cached,
19 memoize, delete_memoized, delete_memoized_verhash
20
21
22 .. autoclass:: CachedResponse
23
24
25 .. autofunction:: make_template_fragment_key
26
27
28 Signals
29 -------
30
31 The following signals are supported:
32
33 .. data:: cache_view_hit
34
35 Sent when a view decorated with :meth:`~Cache.cached` is served from the
36 cache. It is passed ``cache``, the :class:`Cache` instance, ``cache_key``,
37 the key the response was found under, and ``args`` and ``kwargs``, the
38 arguments the view was called with.
39
40 .. data:: cache_view_miss
41
42 Sent when a view decorated with :meth:`~Cache.cached` is not found in the
43 cache and has to be called. It is passed the same arguments as
44 :data:`cache_view_hit`.
45
46 .. data:: cache_memoize_hit
47
48 Sent when a function decorated with :meth:`~Cache.memoize` is served from
49 the cache. In addition to the arguments passed to :data:`cache_view_hit`,
50 it is passed ``f``, the undecorated function.
51
52 .. data:: cache_memoize_miss
53
54 Sent when a function decorated with :meth:`~Cache.memoize` is not found in
55 the cache and has to be called. It is passed the same arguments as
56 :data:`cache_memoize_hit`.
57
58 By default, signals are disabled. To enable sending signals set
59 ``CACHE_ENABLE_SIGNALS`` to ``True``.
60
61 See the `Flask documentation on signals`_ for information on how to use these
62 signals in your code.
63
64
65 .. _Flask documentation on signals: https://flask.palletsprojects.com/en/latest/signals/