feat(redis): refactor Redis configuration to use multiple logical databases

- Updated default REDIS_URL to remove explicit /0 suffix
- Added dedicated Redis clients:
  - db0: general cache (redis_client)
  - db1: message cache (redis_message_client)
  - db2: binary storage (redis_binary_client)
  - db3: rate limiting (redis_rate_limit_client)
- Updated configuration, Docker files, and main startup lifecycle accordingly
- Replaced `get_redis()` usage in notification server with `redis_message_client`
This commit is contained in:
MingxuanGame
2025-10-04 05:39:59 +00:00
parent c2bfafc67a
commit 216d3ab3bf
7 changed files with 53 additions and 27 deletions

View File

@@ -8,7 +8,7 @@ from app.dependencies.database import (
DBFactory,
Redis,
get_db_factory,
get_redis,
redis_message_client,
with_db,
)
from app.dependencies.user import get_current_user_and_token
@@ -31,7 +31,7 @@ class ChatServer:
def __init__(self):
self.connect_client: dict[int, WebSocket] = {}
self.channels: dict[int, list[int]] = {}
self.redis: Redis = get_redis()
self.redis: Redis = redis_message_client
self.tasks: set[asyncio.Task] = set()
self.ChatSubscriber = ChatSubscriber()