From 361a25857b4191e15042b43df8881e58a2d6a88a Mon Sep 17 00:00:00 2001 From: long2ice Date: Wed, 6 Jan 2021 19:57:16 +0800 Subject: [PATCH] bug fix --- Makefile | 2 +- fastapi_cache/decorator.py | 5 ++++- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 021a58c..c0f0381 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ check: deps test: deps $(py_warn) pytest -build: deps +build: clean deps @poetry build clean: diff --git a/fastapi_cache/decorator.py b/fastapi_cache/decorator.py index 8c6052a..cdae9ef 100644 --- a/fastapi_cache/decorator.py +++ b/fastapi_cache/decorator.py @@ -34,7 +34,10 @@ def cache( expire = expire or FastAPICache.get_expire() key_builder = key_builder or FastAPICache.get_key_builder() backend = FastAPICache.get_backend() - cache_key = key_builder(func, namespace, args=args, kwargs=kwargs) + copy_kwargs = kwargs.copy() + copy_kwargs.pop("request", None) + copy_kwargs.pop("response", None) + cache_key = key_builder(func, namespace, args=args, kwargs=copy_kwargs) ttl, ret = await backend.get_with_ttl(cache_key) if not request: if ret is not None: diff --git a/pyproject.toml b/pyproject.toml index 38c3faf..0798ff1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fastapi-cache2" -version = "0.1.3.2" +version = "0.1.3.3" description = "Cache for FastAPI" authors = ["long2ice "] license = "Apache-2.0"