Administrator
2023-08-02 8194d92119c669f4702429df4b1e006d26039693
redis缓存加入内存缓存
1个文件已修改
13 ■■■■ 已修改文件
db/redis_manager.py 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
db/redis_manager.py
@@ -7,11 +7,20 @@
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)