Debian Codegraph @

docs/caches.rst

raw
1 .. _caches:
2
3 Caches
4 ======
5
6 You can use different caches according to your needs. All the caches implement the same interface.
7
8 Caches are always working together with a serializer which transforms data when storing and retrieving from the backend. It may also contain plugins that are able to enrich the behavior of your cache (like adding metrics, logs, etc).
9
10 This is the flow of the ``set`` command:
11
12 .. image:: images/set_operation_flow.png
13 :align: center
14
15 Let's go with a more specific case. Let's pick Redis as the cache with namespace "test" and PickleSerializer as the serializer:
16
17 #. We receive ``set("key", "value")``.
18 #. Hook ``pre_set`` of all attached plugins (none by default) is called.
19 #. "key" will become "test:key" when calling ``build_key``.
20 #. "value" will become an array of bytes when calling ``serializer.dumps`` because of ``PickleSerializer``.
21 #. the byte array is stored together with the key using ``set`` cmd in Redis.
22 #. Hook ``post_set`` of all attached plugins is called.
23
24 By default, all commands are covered by a timeout that will trigger an ``asyncio.TimeoutError`` in case of timeout. Timeout can be set at instance level or when calling the command.
25
26 The supported commands are:
27
28 - add
29 - get
30 - set
31 - multi_get
32 - multi_set
33 - delete
34 - exists
35 - increment
36 - expire
37 - clear
38 - raw
39
40 If you feel a command is missing here do not hesitate to `open an issue <https://github.com/argaen/aiocache/issues>`_
41
42
43 .. _basecache:
44
45 BaseCache
46 ---------
47
48 .. autoclass:: aiocache.base.BaseCache
49 :members:
50
51
52 .. _cache:
53
54 Cache
55 -----
56
57 .. autoclass:: aiocache.Cache
58 :members:
59
60
61 .. _rediscache:
62
63 RedisCache
64 ----------
65
66 .. autoclass:: aiocache.RedisCache
67 :members:
68
69
70 .. _simplememorycache:
71
72 SimpleMemoryCache
73 -----------------
74
75 .. autoclass:: aiocache.SimpleMemoryCache
76 :members:
77
78
79 .. _memcachedcache:
80
81 MemcachedCache
82 --------------
83
84 .. autoclass:: aiocache.MemcachedCache
85 :members: