From 52c61d21a909ffce667c323db2eb921e010f5d5f Mon Sep 17 00:00:00 2001 From: jannchie Date: Thu, 24 Oct 2019 12:32:46 +0900 Subject: [PATCH] fix: redis connection --- db.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/db.py b/db.py index ff8769f..19d4ca1 100644 --- a/db.py +++ b/db.py @@ -12,6 +12,11 @@ os.system('systemctl restart mongod') redis_connect_string = env_dist.get("BILIOB_REDIS_CONNECTION_STRING") - -pool = redis.ConnectionPool(redis_connect_string) # 实现一个连接池 -redis_connection = redis.Redis(connection_pool=pool) +redis_list = redis_connect_string.split(":") +pass_and_ip = redis_list[2].split('@') +password = pass_and_ip[0] +redis_ip = pass_and_ip[1] +redis_port = redis_list[-1] +pool = redis.ConnectionPool(password) # 实现一个连接池 +redis_connection = redis.Redis( + host=redis_ip, port=redis_port, password=password)