summaryrefslogtreecommitdiff
path: root/docs/user_guide.md
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2021-08-20 17:42:29 -0500
committerJordan Cook <jordan.cook@pioneer.com>2021-08-20 20:56:46 -0500
commitd492c56e6870537d02894a31325d23733f2d554b (patch)
tree0f3a50e1ae5136cd910b23e05d4dff8db44f991d /docs/user_guide.md
parent6a672b1b7016fd642ef170b71d946cc4060ce8f9 (diff)
downloadrequests-cache-d492c56e6870537d02894a31325d23733f2d554b.tar.gz
Better serializer docs
Diffstat (limited to 'docs/user_guide.md')
-rw-r--r--docs/user_guide.md24
1 files changed, 21 insertions, 3 deletions
diff --git a/docs/user_guide.md b/docs/user_guide.md
index d259129..4de6358 100644
--- a/docs/user_guide.md
+++ b/docs/user_guide.md
@@ -353,13 +353,21 @@ revalidate the cache with the new expiration time:
By default, responses are serialized using {py:mod}`pickle`. Some other options are also available:
:::{note}
-These features require additional dependencies
+Some serializers require additional dependencies
:::
+### Specifying a Serializer
+Similar to {ref}`backends`, you can specify which serializer to use with the `serializer` parameter
+for either {py:class}`.CachedSession` or {py:func}`.install_cache`.
+
### JSON Serializer
Storing responses as JSON gives you the benefit of making them human-readable and editable, in
-exchange for a slight reduction in performance. This can be especially useful in combination with
-the filesystem backend.
+exchange for a minor reduction in read and write speeds.
+
+Usage:
+```python
+>>> session = CachedSession('my_cache', serializer='json')
+```
:::{admonition} Example JSON-serialized Response
:class: toggle
@@ -376,6 +384,11 @@ pip install requests-cache[json]
### YAML Serializer
YAML is another option if you need a human-readable/editable format, with the same tradeoffs as JSON.
+Usage:
+```python
+>>> session = CachedSession('my_cache', serializer='yaml')
+```
+
:::{admonition} Example YAML-serialized Response
:class: toggle
```{literalinclude} sample_response.yaml
@@ -395,6 +408,11 @@ MongoDB, but it can also be used independently. Compared to JSON, it has better
human-readable, but some tools support reading and editing it directly
(for example, [bson-converter](https://atom.io/packages/bson-converter) for Atom).
+Usage:
+```python
+>>> session = CachedSession('my_cache', serializer='bson')
+```
+
You can install the extra dependencies for this serializer with:
```bash
pip install requests-cache[mongo]