Initialize a new Redis client. To specify a retry policy for specific errors, you have two options: 1. Set the `retry_on_error` to a list of the error/s to retry on, and you can also set `retry` to a valid `Retry` object(in case the default one is not appro
(
self,
host: str = "localhost",
port: int = 6379,
db: int = 0,
password: str | None = None,
socket_timeout: float | None = DEFAULT_SOCKET_TIMEOUT,
socket_connect_timeout: float | None = DEFAULT_SOCKET_CONNECT_TIMEOUT,
socket_read_size: int = DEFAULT_SOCKET_READ_SIZE,
socket_keepalive: bool | None = True,
socket_keepalive_options: Mapping[int, int | bytes] | object | None = SENTINEL,
connection_pool: ConnectionPool | None = None,
unix_socket_path: str | None = None,
encoding: str = "utf-8",
encoding_errors: str = "strict",
decode_responses: bool = False,
retry_on_timeout: bool = False,
retry: Retry = Retry(
backoff=ExponentialWithJitterBackoff(
base=DEFAULT_RETRY_BASE, cap=DEFAULT_RETRY_CAP
),
retries=DEFAULT_RETRY_COUNT,
),
retry_on_error: List[Type[Exception]] | None = None,
ssl: bool = False,
ssl_keyfile: str | None = None,
ssl_certfile: str | None = None,
ssl_cert_reqs: "str | ssl.VerifyMode" = "required",
ssl_include_verify_flags: List["ssl.VerifyFlags"] | None = None,
ssl_exclude_verify_flags: List["ssl.VerifyFlags"] | None = None,
ssl_ca_certs: str | None = None,
ssl_ca_path: str | None = None,
ssl_ca_data: str | None = None,
ssl_check_hostname: bool = True,
ssl_password: str | None = None,
ssl_validate_ocsp: bool = False,
ssl_validate_ocsp_stapled: bool = False,
ssl_ocsp_context: "OpenSSL.SSL.Context | None" = None,
ssl_ocsp_expected_cert: str | None = None,
ssl_min_version: "ssl.TLSVersion | None" = None,
ssl_ciphers: str | None = None,
max_connections: int | None = None,
single_connection_client: bool = False,
health_check_interval: int = 0,
client_name: str | None = None,
lib_name: str | object | None = SENTINEL,
lib_version: str | object | None = SENTINEL,
driver_info: DriverInfo | object | None = SENTINEL,
username: str | None = None,
redis_connect_func: Callable[[], None] | None = None,
credential_provider: CredentialProvider | None = None,
protocol: int | None = None,
legacy_responses: bool = True,
cache: CacheInterface | None = None,
cache_config: CacheConfig | None = None,
event_dispatcher: EventDispatcher | None = None,
maint_notifications_config: MaintNotificationsConfig | None = None,
oss_cluster_maint_notifications_handler: OSSMaintNotificationsHandler
| None = None,
)
| 240 | "lib_name and lib_version will be removed in a future version.", |
| 241 | ) |
| 242 | def __init__( |
| 243 | self, |
| 244 | host: str = "localhost", |
| 245 | port: int = 6379, |
| 246 | db: int = 0, |
| 247 | password: str | None = None, |
| 248 | socket_timeout: float | None = DEFAULT_SOCKET_TIMEOUT, |
| 249 | socket_connect_timeout: float | None = DEFAULT_SOCKET_CONNECT_TIMEOUT, |
| 250 | socket_read_size: int = DEFAULT_SOCKET_READ_SIZE, |
| 251 | socket_keepalive: bool | None = True, |
| 252 | socket_keepalive_options: Mapping[int, int | bytes] | object | None = SENTINEL, |
| 253 | connection_pool: ConnectionPool | None = None, |
| 254 | unix_socket_path: str | None = None, |
| 255 | encoding: str = "utf-8", |
| 256 | encoding_errors: str = "strict", |
| 257 | decode_responses: bool = False, |
| 258 | retry_on_timeout: bool = False, |
| 259 | retry: Retry = Retry( |
| 260 | backoff=ExponentialWithJitterBackoff( |
| 261 | base=DEFAULT_RETRY_BASE, cap=DEFAULT_RETRY_CAP |
| 262 | ), |
| 263 | retries=DEFAULT_RETRY_COUNT, |
| 264 | ), |
| 265 | retry_on_error: List[Type[Exception]] | None = None, |
| 266 | ssl: bool = False, |
| 267 | ssl_keyfile: str | None = None, |
| 268 | ssl_certfile: str | None = None, |
| 269 | ssl_cert_reqs: "str | ssl.VerifyMode" = "required", |
| 270 | ssl_include_verify_flags: List["ssl.VerifyFlags"] | None = None, |
| 271 | ssl_exclude_verify_flags: List["ssl.VerifyFlags"] | None = None, |
| 272 | ssl_ca_certs: str | None = None, |
| 273 | ssl_ca_path: str | None = None, |
| 274 | ssl_ca_data: str | None = None, |
| 275 | ssl_check_hostname: bool = True, |
| 276 | ssl_password: str | None = None, |
| 277 | ssl_validate_ocsp: bool = False, |
| 278 | ssl_validate_ocsp_stapled: bool = False, |
| 279 | ssl_ocsp_context: "OpenSSL.SSL.Context | None" = None, |
| 280 | ssl_ocsp_expected_cert: str | None = None, |
| 281 | ssl_min_version: "ssl.TLSVersion | None" = None, |
| 282 | ssl_ciphers: str | None = None, |
| 283 | max_connections: int | None = None, |
| 284 | single_connection_client: bool = False, |
| 285 | health_check_interval: int = 0, |
| 286 | client_name: str | None = None, |
| 287 | lib_name: str | object | None = SENTINEL, |
| 288 | lib_version: str | object | None = SENTINEL, |
| 289 | driver_info: DriverInfo | object | None = SENTINEL, |
| 290 | username: str | None = None, |
| 291 | redis_connect_func: Callable[[], None] | None = None, |
| 292 | credential_provider: CredentialProvider | None = None, |
| 293 | protocol: int | None = None, |
| 294 | legacy_responses: bool = True, |
| 295 | cache: CacheInterface | None = None, |
| 296 | cache_config: CacheConfig | None = None, |
| 297 | event_dispatcher: EventDispatcher | None = None, |
| 298 | maint_notifications_config: MaintNotificationsConfig | None = None, |
| 299 | oss_cluster_maint_notifications_handler: OSSMaintNotificationsHandler |
no test coverage detected