Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

redis_config.py 3.2KB

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