redis_config.py 825 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from typing import Optional
  2. from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt
  3. class RedisConfig(BaseModel):
  4. """
  5. Redis configs
  6. """
  7. REDIS_HOST: str = Field(
  8. description='Redis host',
  9. default='localhost',
  10. )
  11. REDIS_PORT: PositiveInt = Field(
  12. description='Redis port',
  13. default=6379,
  14. )
  15. REDIS_USERNAME: Optional[str] = Field(
  16. description='Redis username',
  17. default=None,
  18. )
  19. REDIS_PASSWORD: Optional[str] = Field(
  20. description='Redis password',
  21. default=None,
  22. )
  23. REDIS_DB: NonNegativeInt = Field(
  24. description='Redis database id, default to 0',
  25. default=0,
  26. )
  27. REDIS_USE_SSL: bool = Field(
  28. description='whether to use SSL for Redis connection',
  29. default=False,
  30. )