更新时间:2025-08-12 GMT+08:00
Redis健康检查
配置Redis定时健康检查
Redis健康检查的作用是判断Redis服务端是否正常工作,使用health_check_interval配置对Redis进行定时健康检查,该配置单位为秒,默认值为0不进行健康检查,代码如下:
retry = Retry(ExponentialBackoff(), 3)
pool = BlockingConnectionPool(host=redis_host, port=redis_port,
password=redis_password,
max_connections=50, timeout=3,
socket_timeout=2,
socket_connect_timeout=2,
retry=retry,
retry_on_error=[BusyLoadingError,
ConnectionError,
TimeoutError],
health_check_interval=60,
decode_responses=True)
如果业务量大建议不使用该配置,进而减少开销。