From 2a7e23ae3e01e05f2e01f179764e1c9cef71ac70 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 07 八月 2023 13:15:17 +0800
Subject: [PATCH] redis批量提交数据

---
 code_attribute/code_volumn_manager.py |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/code_attribute/code_volumn_manager.py b/code_attribute/code_volumn_manager.py
index ea61607..35295fd 100644
--- a/code_attribute/code_volumn_manager.py
+++ b/code_attribute/code_volumn_manager.py
@@ -21,7 +21,8 @@
     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:
         RedisUtils.realse(redis)
@@ -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()
 
 
 # 鑾峰彇浠婃棩閲�

--
Gitblit v1.8.0