Use configured Redis DB also in sentinel mode

This commit is contained in:
Antoine Nguyen
2025-03-28 12:19:28 +01:00
parent b434958a79
commit 06b82d5ee8
2 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -36,7 +36,9 @@ def get_redis_client():
return aioredis.from_url(
settings.REDIS_URL, encoding="utf-8", decode_responses=True
)
sentinel = aioredis.sentinel.Sentinel(settings.REDIS_SENTINELS, socket_timeout=0.1)
sentinel = aioredis.sentinel.Sentinel(
settings.REDIS_SENTINELS, socket_timeout=0.1, db=settings.REDIS_QUOTA_DB
)
return sentinel.master_for(settings.REDIS_MASTER, socket_timeout=0.1)
+3 -1
View File
@@ -16,7 +16,9 @@ def get_redis_connection():
db=settings.REDIS_QUOTA_DB,
)
else:
sentinel = redis.sentinel.Sentinel(settings.REDIS_SENTINELS, socket_timeout=0.1)
sentinel = redis.sentinel.Sentinel(
settings.REDIS_SENTINELS, socket_timeout=0.1, db=settings.REDIS_QUOTA_DB
)
rclient = sentinel.master_for(settings.REDIS_MASTER, socket_timeout=0.1)
rclient.set_response_callback("HGET", int)
return rclient