update README.md

This commit is contained in:
long2ice
2020-11-12 13:04:50 +08:00
parent 0fd9e53e06
commit 3134e5f67c

View File

@@ -74,6 +74,10 @@ async def startup():
```
### Initialization
Firstly you must call `FastAPICache.init` on startup event of `fastapi`, there are some global config you can pass in.
### Use `cache` decorator
If you want cache `fastapi` response transparently, you can use `cache` as decorator between router decorator and view function and must pass `request` as param of view function.
@@ -95,6 +99,8 @@ async def index(request: Request, response: Response):
### Custom key builder
By default use builtin key builder, if you need, you can override this and pass in `cache` or `FastAPICache.init` to take effect globally.
```python
def my_key_builder(
func,
@@ -116,7 +122,7 @@ async def index(request: Request, response: Response):
### InMemoryBackend
`InMemoryBackend` only support in single node instead of distributed environment.
`InMemoryBackend` store cache data in memory and use lazy delete, which mean if you don't access it after cached, it will not delete automatically.
## License