From 91eb35a77bc8ee2f3ce29cbf9ea7352966cb0038 Mon Sep 17 00:00:00 2001 From: Attente <19653207+wikrin@users.noreply.github.com> Date: Sun, 23 Nov 2025 16:46:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(cache):=20=E4=BF=AE=E5=A4=8Dfresh=E4=BC=9A?= =?UTF-8?q?=E8=A2=AB=E9=94=99=E8=AF=AF=E8=A6=86=E7=9B=96=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/cache.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/core/cache.py b/app/core/cache.py index 0982d5a0..2bb1f1e9 100644 --- a/app/core/cache.py +++ b/app/core/cache.py @@ -1024,13 +1024,11 @@ def fresh(fresh: bool = True): with fresh(): result = some_cached_function() """ - token = _fresh.set(fresh) - logger.debug(f"Setting fresh mode to {fresh}. {id(token):#x}") + token = _fresh.set(fresh or is_fresh()) try: yield finally: _fresh.reset(token) - logger.debug(f"Reset fresh mode. {id(token):#x}") @asynccontextmanager async def async_fresh(fresh: bool = True): @@ -1041,13 +1039,11 @@ async def async_fresh(fresh: bool = True): async with async_fresh(): result = await some_async_cached_function() """ - token = _fresh.set(fresh) - logger.debug(f"Setting async_fresh mode to {fresh}. {id(token):#x}") + token = _fresh.set(fresh or is_fresh()) try: yield finally: _fresh.reset(token) - logger.debug(f"Reset async_fresh mode. {id(token):#x}") def is_fresh() -> bool: """