2024-06-19 13:41:12 +08:00
|
|
|
from typing import Optional
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
from pydantic import Field, NonNegativeInt, PositiveInt
|
|
|
|
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
|
|
|
"""
|
|
|
|
Redis configs
|
|
|
|
"""
|
2024-08-23 23:46:01 +08:00
|
|
|
|
2024-06-19 13:41:12 +08:00
|
|
|
REDIS_HOST: str = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="Redis host",
|
|
|
|
default="localhost",
|
2024-06-19 13:41:12 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_PORT: PositiveInt = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="Redis port",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=6379,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_USERNAME: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="Redis username",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_PASSWORD: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="Redis password",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_DB: NonNegativeInt = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="Redis database id, default to 0",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=0,
|
|
|
|
)
|
|
|
|
|
|
|
|
REDIS_USE_SSL: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="whether to use SSL for Redis connection",
|
2024-06-19 13:41:12 +08:00
|
|
|
default=False,
|
|
|
|
)
|