Administrator
2022-09-08 e7f8c6013d777dd5ba10b8d548d2d3db6158d37a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import redis
 
config = {
    "host": "127.0.0.1",
    "port": 6379,
    "db": 0,
    "pwd": "123456"
}
 
 
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)
 
    def getRedis(self):
        return redis.Redis(connection_pool=self.pool)