From 5f436eb8b6da6ec1d4863cbe3ea70e6dcd909894 Mon Sep 17 00:00:00 2001 From: Erin of Yukis Date: Mon, 21 Apr 2025 09:56:08 +0200 Subject: [PATCH] Use `redis.from_url`, rather than the seperate fields in Modoboa policyd This is the suggested way to handle all of TCP/TLS/Unix in a compact way by the redis-py project: https://redis.readthedocs.io/en/stable/examples/connection_examples.html#Connecting-to-Redis-instances-by-specifying-a-URL-scheme. It also makes it possible to specify extra connection arguments in a consistent way for all Redis clients used by Modoboa. --- modoboa/lib/redis.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modoboa/lib/redis.py b/modoboa/lib/redis.py index e6f06c701..d03624b04 100644 --- a/modoboa/lib/redis.py +++ b/modoboa/lib/redis.py @@ -6,11 +6,7 @@ from django.conf import settings def get_redis_connection(hget_return_type=int) -> redis.Redis: """Return a client connection to Redis server.""" if not getattr(settings, "REDIS_SENTINEL", False): - rclient = redis.Redis( - host=settings.REDIS_HOST, - port=settings.REDIS_PORT, - db=settings.REDIS_QUOTA_DB, - ) + rclient = redis.from_url(settings.REDIS_URL) else: sentinel = redis.sentinel.Sentinel( settings.REDIS_SENTINELS, socket_timeout=0.1, db=settings.REDIS_QUOTA_DB