1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| """
| redis管理器
| """
| import redis
|
| import constant
|
| config = constant.REDIS_CONFIG
|
| pool_cache = {}
|
|
| class RedisManager:
|
| def __init__(self, db=config["db"]):
| 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)
|
|
| if __name__ == "__main__":
| _redisManager = RedisManager(0)
| redis = _redisManager.getRedis()
| keys = redis.keys("volumn_max60-*")
| for k in keys:
| # print(k)
| redis.delete(k)
|
| pass
|
|