Bläddra i källkod

修改连接方式

locky 1 år sedan
förälder
incheckning
d33bc15e12
1 ändrade filer med 4 tillägg och 2 borttagningar
  1. 4 2
      Object/RedisObject.py

+ 4 - 2
Object/RedisObject.py

@@ -1,6 +1,7 @@
 import redis
 import rediscluster
 from rediscluster import ClusterConnectionPool
+from rediscluster import RedisCluster
 from AnsjerPush.config import REDIS_ADDRESS, CONFIG_INFO, CONFIG_US
 
 # 本地调试把注释打开
@@ -12,8 +13,9 @@ class RedisObject:
     def __init__(self, db=0):
         if CONFIG_INFO == CONFIG_US:
             from AnsjerPush.config import STARTUP_NODES, REDIS_PASSWORD
-            pool = ClusterConnectionPool(startup_nodes=STARTUP_NODES, password=REDIS_PASSWORD, max_connections=100)
-            self.CONN = rediscluster.RedisCluster(connection_pool=pool)
+            # pool = ClusterConnectionPool(startup_nodes=STARTUP_NODES, password=REDIS_PASSWORD, max_connections=100)
+            # self.CONN = rediscluster.RedisCluster(connection_pool=pool)
+            self.CONN = RedisCluster(startup_nodes=STARTUP_NODES, decode_responses=True, password=REDIS_PASSWORD)
         else:
             pool = redis.ConnectionPool(host=REDIS_ADDRESS, port=6379, db=db)
             self.CONN = redis.Redis(connection_pool=pool)