| | |
| | | |
| | | def __init__(self, db=config["db"]): |
| | | self.pool = pool_caches[db] |
| | | self.db = db |
| | | |
| | | def getRedis(self): |
| | | return redis.Redis(connection_pool=self.pool) |
| | | |
| | | def getRedisNoPool(self): |
| | | return redis.Redis(host=config["host"], port=config["port"], password=config["pwd"], db=self.db, |
| | | decode_responses=True) |
| | | |
| | | |
| | | class RedisUtils: |
| | | @classmethod |
| | |
| | | # 读取消息 |
| | | def read_msg(self, client_id): |
| | | if client_id in self.__queue_dict: |
| | | try: |
| | | return self.__queue_dict[client_id].get(block=False) |
| | | except: |
| | | pass |
| | | return None |
| | | |
| | | |
| | |
| | | return_str = json.dumps( |
| | | {"code": 0, "data": fdata, "msg": ""}) |
| | | elif type_ == 'test_redis': |
| | | redis = redis_manager.RedisManager(5).getRedis() |
| | | redis = redis_manager.RedisManager(5).getRedisNoPool() |
| | | try: |
| | | _start_time = time.time() |
| | | times = [] |
| | |
| | | return_str = json.dumps( |
| | | {"code": 0, "data": times, "msg": ""}) |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | | redis.close() |
| | | # RedisUtils.realse(redis) |
| | | |
| | | # 查询委托列表 |
| | | elif type_ == 'test': |