Add enable param to init

This commit is contained in:
long2ice
2021-10-28 15:52:21 +08:00
parent 4faa5b7101
commit 9928f4cda0
3 changed files with 11 additions and 1 deletions

View File

@@ -29,7 +29,9 @@ def cache(
copy_kwargs = kwargs.copy()
request = copy_kwargs.pop("request", None)
response = copy_kwargs.pop("response", None)
if request and request.headers.get("Cache-Control") == "no-store":
if (
request and request.headers.get("Cache-Control") == "no-store"
) or not FastAPICache.get_enable():
return await func(*args, **kwargs)
coder = coder or FastAPICache.get_coder()