feat: optimize code

This commit is contained in:
martsforever
2025-10-19 20:26:55 +08:00
parent cb54ef584a
commit c17f06f7c5
2 changed files with 4 additions and 1 deletions
+2 -1
View File
@@ -71,7 +71,8 @@ async def get_redis_cache(key: str, default_value_getter):
async with redis_utils.get_redis_connection() as redis_client:
# default_value_getter返回的字段可能嵌套多层对象,这里改成用json字符串缓存
json_string = await redis_client.get(key)
exists = bool(json_string)
exists = False if json_string == "{}" else bool(json_string)
# print("exists", exists)
if exists:
return json.loads(json_string)
else: