| | |
| | | """ |
| | | |
| | | # 大单管理 |
| | | from db import redis_manager |
| | | from db.redis_manager import RedisUtils |
| | | from db import redis_manager_delegate as redis_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from utils import tool |
| | | |
| | | __redisManager = redis_manager.RedisManager(0) |
| | | __db = 0 |
| | | __redisManager = redis_manager.RedisManager(__db) |
| | | |
| | | |
| | | # 是否为大单 |
| | | def is_big_num(val): |
| | | if int(val["num"]) >= 8000 or int(val["num"]) * float(val["price"]) >= 30000: |
| | | if int(val["num"]) >= 8999 or int(val["num"]) * float(val["price"]) >= 29900: |
| | | return True |
| | | else: |
| | | return False |
| | | |
| | | |
| | | __big_money_cache = {} |
| | | |
| | | |
| | | def add_num(code, num): |
| | | RedisUtils.incrby(__redisManager.getRedis(), "big_money-{}".format(code), num) |
| | | if code not in __big_money_cache: |
| | | __big_money_cache[code] = 0 |
| | | __big_money_cache[code] += num |
| | | RedisUtils.incrby_async(__db, "big_money-{}".format(code), num) |
| | | |
| | | |
| | | # 设置过期时间 |
| | |
| | | |
| | | |
| | | def reset(code): |
| | | __big_money_cache[code] = 0 |
| | | RedisUtils.set(__redisManager.getRedis(), "big_money-{}".format(code), 0) |
| | | |
| | | |
| | |
| | | return round(int(num) / 1000 / 4) |
| | | |
| | | |
| | | def get_num_cache(code): |
| | | if code in __big_money_cache: |
| | | return __big_money_cache[code] |
| | | num = get_num(code) |
| | | __big_money_cache[code] = num |
| | | return num |
| | | |
| | | |
| | | def reset_all(): |
| | | redis = __redisManager.getRedis() |
| | | try: |
| | |
| | | for k in keys: |
| | | RedisUtils.setex(redis, k, tool.get_expire(), 0, auto_free=False) |
| | | finally: |
| | | redis.connection_pool.disconnect() |
| | | RedisUtils.realse(redis) |
| | | |
| | | |
| | | if __name__ == "__main__": |