From 0de513cda42273d5d901e97d5409b5543b2fb1bf Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sat, 15 Mar 2025 17:54:06 +0800 Subject: [PATCH] Refine --- main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index d97646e..11dc0bb 100644 --- a/main.py +++ b/main.py @@ -2172,14 +2172,14 @@ async def fastapi_query_all_records_by_ids_date_type(ids:str, querydate: str, qu global redis_client cache_key = f"queryallrecordsbydatewithtype_{querydate}_{querytype}" data = redis_client.get(cache_key) + results = [] if data: # 使用自定义的反序列化函数 - loaded_dict = msgpack.unpackb(data, object_hook=object_hook) - return loaded_dict - - results = influxdb_api.query_all_records_by_date_with_type(query_date=querydate, query_type=querytype, client=influx_client) - packed = msgpack.packb(results, default=default_encoder) - redis_client.set(cache_key, packed) + results = msgpack.unpackb(data, object_hook=object_hook) + else: + results = influxdb_api.query_all_records_by_date_with_type(query_date=querydate, query_type=querytype, client=influx_client) + packed = msgpack.packb(results, default=default_encoder) + redis_client.set(cache_key, packed) query_ids = ids.split(",") logger.info("ids", ids)