From 81e418f1aa222a4121daad6e2ca995256a94be77 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 24 Jul 2025 11:03:13 +0800 Subject: [PATCH] perf: User cache --- backend/common/core/sqlbot_cache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/common/core/sqlbot_cache.py b/backend/common/core/sqlbot_cache.py index e13bc607..e3fe8482 100644 --- a/backend/common/core/sqlbot_cache.py +++ b/backend/common/core/sqlbot_cache.py @@ -124,6 +124,8 @@ def cache( result = await func(*args, **kwargs) actual_expire = expire + random.randint(-jitter, jitter) + if await backend.get(cache_key): + await backend.clear(cache_key) await backend.set(cache_key, result, actual_expire) SQLBotLogUtil.debug(f"Cache set: {cache_key} (expire: {actual_expire}s)")