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.
This commit is contained in:
Erin of Yukis
2025-08-13 08:31:34 +02:00
parent aa629e5627
commit 5f436eb8b6
+1 -5
View File
@@ -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