diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/_static/dynamodb_items.png | bin | 0 -> 69437 bytes | |||
-rw-r--r-- | docs/_static/dynamodb_response.png | bin | 0 -> 124237 bytes | |||
-rw-r--r-- | docs/user_guide/backends/dynamodb.md | 60 | ||||
-rw-r--r-- | docs/user_guide/backends/mongodb.md | 9 |
4 files changed, 47 insertions, 22 deletions
diff --git a/docs/_static/dynamodb_items.png b/docs/_static/dynamodb_items.png Binary files differnew file mode 100644 index 0000000..3ab4531 --- /dev/null +++ b/docs/_static/dynamodb_items.png diff --git a/docs/_static/dynamodb_response.png b/docs/_static/dynamodb_response.png Binary files differnew file mode 100644 index 0000000..9e2bae0 --- /dev/null +++ b/docs/_static/dynamodb_response.png diff --git a/docs/user_guide/backends/dynamodb.md b/docs/user_guide/backends/dynamodb.md index 247b044..0758c1c 100644 --- a/docs/user_guide/backends/dynamodb.md +++ b/docs/user_guide/backends/dynamodb.md @@ -36,7 +36,50 @@ This backend accepts any keyword arguments for {py:meth}`boto3.session.Session.r >>> session = CachedSession(backend=backend) ``` -## Table +## Viewing Responses +By default, responses are only partially serialized so they can be saved as plain DynamoDB +documents. Response data can then be easily viewed via the +[AWS Console](https://aws.amazon.com/console/). + +Here is an example of responses listed under **DynamoDB > Tables > Explore Items:** +:::{admonition} Screenshot +:class: toggle +```{image} ../../_static/dynamodb_items.png +``` +::: + +And here is an example response: +:::{admonition} Screenshot +:class: toggle +```{image} ../../_static/dynamodb_response.png +``` +::: + +It is also possible query these responses with the [AWS CLI](https://aws.amazon.com/cli), for example: +```bash +aws dynamodb query \ + --table-name http_cache \ + --key-condition-expression "namespace = :n1" \ + --expression-attribute-values '{":n1": {"S": "responses"}}' \ + > responses.json +``` + +## Expiration +DynamoDB natively supports TTL on a per-item basis, and can automatically remove expired responses from +the cache. This will be set by by default, according to normal {ref}`expiration settings <expiration>`. + +```{warning} +DynamoDB does not remove expired items immediately. See +[How It Works: DynamoDB Time to Live](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html) +for more details. +``` + +If needed, you can disable this behavior with the `ttl` argument: +```python +>>> backend = DynamoDbCache(ttl=False) +``` + +## Creating a Table A table will be automatically created if one doesn't already exist. This is convienient if you just want to quickly test out DynamoDB as a cache backend, but in a production environment you will likely want to create the tables yourself, for example with @@ -66,18 +109,3 @@ aws cloudformation deploy \ --stack-name requests-cache \ --template-file examples/cloudformation.yml ``` - -## Expiration -DynamoDB natively supports TTL on a per-item basis, and can automatically remove expired responses from -the cache. This will be set by by default, according to normal {ref}`expiration settings <expiration>`. - -```{warning} -DynamoDB does not remove expired items immediately. See -[How It Works: DynamoDB Time to Live](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html) -for more details. -``` - -If needed, you can disable this behavior with the `ttl` argument: -```python ->>> backend = DynamoDbCache(ttl=False) -``` diff --git a/docs/user_guide/backends/mongodb.md b/docs/user_guide/backends/mongodb.md index 11201b2..4b504cc 100644 --- a/docs/user_guide/backends/mongodb.md +++ b/docs/user_guide/backends/mongodb.md @@ -33,19 +33,16 @@ This backend accepts any keyword arguments for {py:class}`pymongo.mongo_client.M ``` ## Viewing Responses -Unlike most of the other backends, response data can be easily viewed via the +By default, responses are only partially serialized so they can be saved as plain MongoDB documents. +Response data can be easily viewed via the [MongoDB shell](https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh), -[Compass](https://www.mongodb.com/products/compass), or any other interface for MongoDB. This is -possible because its internal document format ([BSON](https://www.mongodb.com/json-and-bson)) -supports all the types needed to store a response as a plain document rather than a fully serialized -blob. +[Compass](https://www.mongodb.com/products/compass), or any other interface for MongoDB. Here is an example response viewed in [MongoDB for VSCode](https://code.visualstudio.com/docs/azure/mongodb): :::{admonition} Screenshot :class: toggle - ```{image} ../../_static/mongodb_vscode.png ``` ::: |