Update README & add usage

This commit is contained in:
Jimmy
2021-09-29 16:22:04 +02:00
parent d67797a1d5
commit a40c54e9e7
2 changed files with 14 additions and 2 deletions

View File

@@ -7,11 +7,11 @@
## Introduction ## Introduction
`fastapi-cache` is a tool to cache fastapi response and function result, with backends support `redis` and `memcache`. `fastapi-cache` is a tool to cache fastapi response and function result, with backends support `redis`, `memcache`, and `dynamodb`.
## Features ## Features
- Support `redis` and `memcache` and `in-memory` backends. - Support `redis`, `memcache`, `dynamodb`, and `in-memory` backends.
- Easily integration with `fastapi`. - Easily integration with `fastapi`.
- Support http cache like `ETag` and `Cache-Control`. - Support http cache like `ETag` and `Cache-Control`.
@@ -20,6 +20,7 @@
- `asyncio` environment. - `asyncio` environment.
- `redis` if use `RedisBackend`. - `redis` if use `RedisBackend`.
- `memcache` if use `MemcacheBackend`. - `memcache` if use `MemcacheBackend`.
- `aiobotocore` if use `DynamoBackend`.
## Install ## Install
@@ -39,6 +40,12 @@ or
> pip install "fastapi-cache2[memcache]" > pip install "fastapi-cache2[memcache]"
``` ```
or
```shell
> pip install "fastapi-cache2[dynamodb]"
```
## Usage ## Usage
### Quick Start ### Quick Start

View File

@@ -17,6 +17,11 @@ class DynamoBackend(Backend):
As with all AWS clients, credentials will be taken from the environment. Check the AWS SDK As with all AWS clients, credentials will be taken from the environment. Check the AWS SDK
for more information. for more information.
Usage:
>> dynamodb = DynamoBackend(table_name="your-cache", region="eu-west-1")
>> await dynamodb.init()
>> FastAPICache.init(dynamodb)
""" """
def __init__(self, table_name, region=None): def __init__(self, table_name, region=None):