feat: optimize code
This commit is contained in:
@@ -20,6 +20,8 @@ async def perform_general_operation(
|
|||||||
|
|
||||||
module_query_result = await get_module_config(session, module, debug_data, user)
|
module_query_result = await get_module_config(session, module, debug_data, user)
|
||||||
|
|
||||||
|
# print("module_query_result", module_query_result)
|
||||||
|
|
||||||
if 'error' in module_query_result:
|
if 'error' in module_query_result:
|
||||||
return module_query_result
|
return module_query_result
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ async def get_redis_cache(key: str, default_value_getter):
|
|||||||
async with redis_utils.get_redis_connection() as redis_client:
|
async with redis_utils.get_redis_connection() as redis_client:
|
||||||
# default_value_getter返回的字段可能嵌套多层对象,这里改成用json字符串缓存
|
# default_value_getter返回的字段可能嵌套多层对象,这里改成用json字符串缓存
|
||||||
json_string = await redis_client.get(key)
|
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:
|
if exists:
|
||||||
return json.loads(json_string)
|
return json.loads(json_string)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user