2024-06-19 13:41:12 +08:00
|
|
|
from typing import Optional
|
|
|
|
|
2024-09-08 13:23:51 +08:00
|
|
|
from pydantic import Field, NonNegativeInt, PositiveFloat, PositiveInt
|
2024-07-07 12:18:15 +08:00
|
|
|
from pydantic_settings import BaseSettings
|
2024-06-19 13:41:12 +08:00
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class RedisConfig(BaseSettings):
|
2024-06-19 13:41:12 +08:00
|
|
|
"""
|
2024-09-22 12:38:41 +07:00
|
|
|
Configuration settings for Redis connection
|
2024-06-19 13:41:12 +08:00
|
|
|
"""
|
2024-08-23 23:46:01 +08:00
|
|
|
|
2024-06-19 13:41:12 +08:00
|
|
|
REDIS_HOST: str = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Hostname or IP address of the Redis server",
|
2024-08-23 23:46:01 +08:00
|
|
|
default="localhost",
|
2024-06-19 13:41:12 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_PORT: PositiveInt = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Port number on which the Redis server is listening",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=6379,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_USERNAME: Optional[str] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Username for Redis authentication (if required)",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_PASSWORD: Optional[str] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Password for Redis authentication (if required)",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_DB: NonNegativeInt = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Redis database number to use (0-15)",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=0,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_USE_SSL: bool = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Enable SSL/TLS for the Redis connection",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=False,
|
|
|
|
)
|
2024-09-08 13:23:51 +08:00
|
|
|
|
|
|
|
REDIS_USE_SENTINEL: Optional[bool] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Enable Redis Sentinel mode for high availability",
|
2024-09-08 13:23:51 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_SENTINELS: Optional[str] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Comma-separated list of Redis Sentinel nodes (host:port)",
|
2024-09-08 13:23:51 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_SENTINEL_SERVICE_NAME: Optional[str] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Name of the Redis Sentinel service to monitor",
|
2024-09-08 13:23:51 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_SENTINEL_USERNAME: Optional[str] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Username for Redis Sentinel authentication (if required)",
|
2024-09-08 13:23:51 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_SENTINEL_PASSWORD: Optional[str] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Password for Redis Sentinel authentication (if required)",
|
2024-09-08 13:23:51 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_SENTINEL_SOCKET_TIMEOUT: Optional[PositiveFloat] = Field(
|
2024-09-22 12:38:41 +07:00
|
|
|
description="Socket timeout in seconds for Redis Sentinel connections",
|
2024-09-08 13:23:51 +08:00
|
|
|
default=0.1,
|
|
|
|
)
|
2024-11-20 13:44:35 +08:00
|
|
|
|
|
|
|
REDIS_USE_CLUSTERS: bool = Field(
|
|
|
|
description="Enable Redis Clusters mode for high availability",
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_CLUSTERS: Optional[str] = Field(
|
|
|
|
description="Comma-separated list of Redis Clusters nodes (host:port)",
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_CLUSTERS_PASSWORD: Optional[str] = Field(
|
|
|
|
description="Password for Redis Clusters authentication (if required)",
|
|
|
|
default=None,
|
|
|
|
)
|
2025-05-12 09:34:25 +08:00
|
|
|
|
|
|
|
REDIS_SERIALIZATION_PROTOCOL: int = Field(
|
|
|
|
description="Redis serialization protocol (RESP) version",
|
|
|
|
default=3,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_ENABLE_CLIENT_SIDE_CACHE: bool = Field(
|
|
|
|
description="Enable client side cache in redis",
|
|
|
|
default=True,
|
|
|
|
)
|