mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user