| | |
| | | # 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) |
| | |
| | | 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) |
| | |
| | | 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() |
| | | |
| | | |
| | | # 获取今日量 |