| | |
| | | |
| | | config = constant.REDIS_CONFIG |
| | | |
| | | pool_cache = {} |
| | | |
| | | |
| | | class RedisManager: |
| | | |
| | | def __init__(self, db=config["db"]): |
| | | self.pool = redis.ConnectionPool(host=config["host"], port=config["port"], password=config["pwd"], |
| | | db=db, decode_responses=True) |
| | | pool = None |
| | | if db in pool_cache: |
| | | pool = pool_cache[db] |
| | | else: |
| | | pool = redis.ConnectionPool(host=config["host"], port=config["port"], password=config["pwd"], |
| | | db=db, decode_responses=True, max_connections=200) |
| | | pool_cache[db] = pool |
| | | self.pool = pool |
| | | |
| | | def getRedis(self): |
| | | return redis.Redis(connection_pool=self.pool) |