Created
December 25, 2024 08:06
-
-
Save vndee/4c1f5c769e4fd30d33414f245ad09b79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from redis_data_structures import ConnectionManager | |
from datetime import timedelta | |
conn = ConnectionManager( | |
host='redis.example.com', | |
max_connections=20, | |
retry_max_attempts=5, | |
circuit_breaker_threshold=10, | |
circuit_breaker_timeout=timedelta(minutes=5), | |
ssl=True | |
) | |
# The circuit breaker prevents cascade failures | |
try: | |
with conn.get_connection() as redis: | |
redis.ping() | |
except CircuitBreakerOpen: | |
# Handle degraded state gracefully | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment