From ba52d7ac92a36f413eacaa686f8535e859664ec6 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 28 八月 2023 09:45:11 +0800
Subject: [PATCH] bug修改

---
 code_attribute/code_volumn_manager.py |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/code_attribute/code_volumn_manager.py b/code_attribute/code_volumn_manager.py
index 0849d48..89332a2 100644
--- a/code_attribute/code_volumn_manager.py
+++ b/code_attribute/code_volumn_manager.py
@@ -7,9 +7,9 @@
 # yesterday 鏄ㄥぉ鐨勯噺
 import json
 
-from db.redis_manager import RedisUtils
+from db.redis_manager_delegate import RedisUtils
 from utils import global_util, tool
-from db import redis_manager
+from db import redis_manager_delegate as redis_manager
 from log_module.log import logger_day_volumn
 
 __redis_manager = redis_manager.RedisManager(0)
@@ -21,10 +21,11 @@
     global_util.max60_volumn[code] = (max60, max60_day)
     global_util.yesterday_volumn[code] = yesterday
     try:
-        RedisUtils.setex(redis, "volumn_max60-{}".format(code), tool.get_expire(), json.dumps((max60, max60_day)), auto_free=False)
+        RedisUtils.setex(redis, "volumn_max60-{}".format(code), tool.get_expire(), json.dumps((max60, max60_day)),
+                         auto_free=False)
         RedisUtils.setex(redis, "volumn_yes-{}".format(code), tool.get_expire(), yesterday, auto_free=False)
     finally:
-        redis.connection_pool.disconnect()
+        RedisUtils.realse(redis)
 
 
 # 鑾峰彇鍘嗗彶閲�
@@ -41,7 +42,7 @@
             yesterday = RedisUtils.get(redis, "volumn_yes-{}".format(code), auto_free=False)
         return max60, yesterday
     finally:
-        redis.connection_pool.disconnect()
+        RedisUtils.realse(redis)
 
 
 __today_volumn_cache = {}
@@ -57,7 +58,22 @@
     if code in __today_volumn_cache and volumn - __today_volumn_cache[code] < 100000:
         return
     __today_volumn_cache[code] = volumn
-    RedisUtils.setex( __redis_manager.getRedis(), "volumn_today-{}".format(code), tool.get_expire(), volumn)
+    RedisUtils.setex(__redis_manager.getRedis(), "volumn_today-{}".format(code), tool.get_expire(), volumn)
+
+
+# datas:[(code, volumn)]
+def set_today_volumns(datas):
+    pipe = __redis_manager.getRedis().pipeline()
+    for d in datas:
+        code, volumn = d
+        logger_day_volumn.info("code:{} volumn:{}".format(code, volumn))
+        global_util.today_volumn[code] = volumn
+        # 鏈�1000鎵嬬殑鍙樺寲鎵嶄繚瀛�
+        if code in __today_volumn_cache and volumn - __today_volumn_cache[code] < 100000:
+            continue
+        __today_volumn_cache[code] = volumn
+        RedisUtils.setex(pipe, "volumn_today-{}".format(code), tool.get_expire(), volumn)
+    pipe.execute()
 
 
 # 鑾峰彇浠婃棩閲�
@@ -120,7 +136,7 @@
                 code = k.split("-")[1]
                 global_util.yesterday_volumn[code] = RedisUtils.get(redis, k, auto_free=False)
     finally:
-        redis.connection_pool.disconnect()
+        RedisUtils.realse(redis)
 
 
 if __name__ == "__main__":

--
Gitblit v1.8.0