From 3134e5f67c40c0e05a806f8a9fa60f8474c44f9a Mon Sep 17 00:00:00 2001 From: long2ice Date: Thu, 12 Nov 2020 13:04:50 +0800 Subject: [PATCH] update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f6b184..01482f1 100644 --- a/README.md +++ b/README.md @@ -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