You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced.rst
+20-7Lines changed: 20 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,24 +5,37 @@ Advanced Section
5
5
Caching
6
6
**********
7
7
8
-
By default, caching is **disabled**. You can enable the built-in in-memory cache by passing :code:`use_cache=True`:
8
+
The packaged :py:class:`Client` and :py:class:`AsyncClient` do not come with any built-in caching.
9
+
A convenient option is to use the :py:class:`niquests_cache.session.CachedSession` or :py:class:`niquests_cache.session.AsyncCachedSession` classes from the `niquests_cache` library.
This creates an in-memory cache that expires after 300 seconds. You can adjust the `expire_after` value to fit your needs or set it to `-1` to disable expiration.
31
+
For more information on the available caching options, see the `niquests_cache <https://niquests-cache.readthedocs.io/en/stable/>` documentation.
15
32
16
-
This creates an in-memory cache that expires after 300 seconds.
17
33
18
34
Persistent Caching
19
35
********************
20
36
21
37
If you want your cache to persist between runs (e.g. to a filesystem), you can pass your own custom cached session via the :code:`session` parameter.
22
38
23
-
Depending on whether you are using a sync or async client you will want to use either :py:class:`niquests_cache.session.CachedSession` or :py:class:`niquests_cache.session.AsyncCachedSession` respectively.
24
-
See the docs for `niquests_cache <https://niquests-cache.readthedocs.io/en/stable/#example-usage>`__ for backend options and more.
25
-
26
39
.. code-block:: python
27
40
28
41
from datetime import timedelta
@@ -32,7 +45,7 @@ See the docs for `niquests_cache <https://niquests-cache.readthedocs.io/en/stabl
32
45
client = Client(
33
46
"<API_URL>",
34
47
"<TOKEN>",
35
-
session=CachedSession(cache_name=Path('.cache') /'http'), #defaults to sqlite cache
0 commit comments