您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

redis_config.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. from typing import Optional
  2. from pydantic import Field, NonNegativeInt, PositiveFloat, PositiveInt
  3. from pydantic_settings import BaseSettings
  4. class RedisConfig(BaseSettings):
  5. """
  6. Configuration settings for Redis connection
  7. """
  8. REDIS_HOST: str = Field(
  9. description="Hostname or IP address of the Redis server",
  10. default="localhost",
  11. )
  12. REDIS_PORT: PositiveInt = Field(
  13. description="Port number on which the Redis server is listening",
  14. default=6379,
  15. )
  16. REDIS_USERNAME: Optional[str] = Field(
  17. description="Username for Redis authentication (if required)",
  18. default=None,
  19. )
  20. REDIS_PASSWORD: Optional[str] = Field(
  21. description="Password for Redis authentication (if required)",
  22. default=None,
  23. )
  24. REDIS_DB: NonNegativeInt = Field(
  25. description="Redis database number to use (0-15)",
  26. default=0,
  27. )
  28. REDIS_USE_SSL: bool = Field(
  29. description="Enable SSL/TLS for the Redis connection",
  30. default=False,
  31. )
  32. REDIS_SSL_CERT_REQS: str = Field(
  33. description="SSL certificate requirements (CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED)",
  34. default="CERT_NONE",
  35. )
  36. REDIS_SSL_CA_CERTS: Optional[str] = Field(
  37. description="Path to the CA certificate file for SSL verification",
  38. default=None,
  39. )
  40. REDIS_SSL_CERTFILE: Optional[str] = Field(
  41. description="Path to the client certificate file for SSL authentication",
  42. default=None,
  43. )
  44. REDIS_SSL_KEYFILE: Optional[str] = Field(
  45. description="Path to the client private key file for SSL authentication",
  46. default=None,
  47. )
  48. REDIS_USE_SENTINEL: Optional[bool] = Field(
  49. description="Enable Redis Sentinel mode for high availability",
  50. default=False,
  51. )
  52. REDIS_SENTINELS: Optional[str] = Field(
  53. description="Comma-separated list of Redis Sentinel nodes (host:port)",
  54. default=None,
  55. )
  56. REDIS_SENTINEL_SERVICE_NAME: Optional[str] = Field(
  57. description="Name of the Redis Sentinel service to monitor",
  58. default=None,
  59. )
  60. REDIS_SENTINEL_USERNAME: Optional[str] = Field(
  61. description="Username for Redis Sentinel authentication (if required)",
  62. default=None,
  63. )
  64. REDIS_SENTINEL_PASSWORD: Optional[str] = Field(
  65. description="Password for Redis Sentinel authentication (if required)",
  66. default=None,
  67. )
  68. REDIS_SENTINEL_SOCKET_TIMEOUT: Optional[PositiveFloat] = Field(
  69. description="Socket timeout in seconds for Redis Sentinel connections",
  70. default=0.1,
  71. )
  72. REDIS_USE_CLUSTERS: bool = Field(
  73. description="Enable Redis Clusters mode for high availability",
  74. default=False,
  75. )
  76. REDIS_CLUSTERS: Optional[str] = Field(
  77. description="Comma-separated list of Redis Clusters nodes (host:port)",
  78. default=None,
  79. )
  80. REDIS_CLUSTERS_PASSWORD: Optional[str] = Field(
  81. description="Password for Redis Clusters authentication (if required)",
  82. default=None,
  83. )
  84. REDIS_SERIALIZATION_PROTOCOL: int = Field(
  85. description="Redis serialization protocol (RESP) version",
  86. default=3,
  87. )
  88. REDIS_ENABLE_CLIENT_SIDE_CACHE: bool = Field(
  89. description="Enable client side cache in redis",
  90. default=False,
  91. )