diff --git a/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py b/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py index e2bf19166..b4ffc33e0 100644 --- a/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py +++ b/forms-flow-api-utils/src/formsflow_api_utils/utils/caching.py @@ -5,17 +5,8 @@ from redis.client import Redis import json import os -from redis.cluster import RedisCluster -from urllib.parse import urlparse +from redis import ConnectionPool -def get_cluster_startup_nodes(cluster_url): - parsed_url = urlparse(cluster_url) - hosts_ports = parsed_url.netloc.split(',') - startup_nodes = [] - for host_port in hosts_ports: - host, port = host_port.split(':') - startup_nodes.append({"host": host, "port": int(port)}) - return startup_nodes class RedisManager: """ @@ -44,9 +35,8 @@ def get_client(cls, app=None) -> Redis: if app is None: app = current_app redis_url = app.config.get("REDIS_URL") - startup_nodes = get_cluster_startup_nodes(redis_url) if redis_cluster: - cls._redis_client = RedisCluster(startup_nodes=startup_nodes, decode_responses=True) + cls._redis_client = redis.StrictRedis.from_url(redis_url, decode_responses=True, connection_pool=ConnectionPool.from_url(redis_url), cluster=True) else: cls._redis_client = redis.StrictRedis.from_url(redis_url) app.logger.info("Redis client initiated successfully")