Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(caching): log a refused async_increment as debug while the breaker is open

mateo-berriad607516a278
diff --git a/litellm/caching/dual_cache.py b/litellm/caching/dual_cache.py
index d4764f15e72..78381f740c1 100644
--- a/litellm/caching/dual_cache.py
+++ b/litellm/caching/dual_cache.py
@@ -410,8 +410,10 @@ class DualCache(BaseCache):
return result
except Exception as e:
- verbose_logger.warning(
- "Redis async_increment_cache failed, falling back to in-memory result: %s",
+ log_redis_failure(
+ verbose_logger,
+ logging.WARNING,
+ "Redis async_increment_cache failed, falling back to in-memory result",
e,
)
return result
diff --git a/tests/test_litellm/caching/test_dual_cache.py b/tests/test_litellm/caching/test_dual_cache.py
index 29b5d467b39..b0c17507adb 100644
--- a/tests/test_litellm/caching/test_dual_cache.py
+++ b/tests/test_litellm/caching/test_dual_cache.py
@@ -610,6 +610,10 @@ class _OpenBreakerRedis:
async def async_increment_pipeline(self, increment_list, **kwargs):
raise AssertionError("never reached")
+ @_redis_circuit_breaker_guard
+ async def async_increment(self, key, value, **kwargs):
+ raise AssertionError("never reached")
+
@_redis_circuit_breaker_guard_sync
def get_cache(self, key, **kwargs):
raise AssertionError("never reached")
@@ -630,8 +634,9 @@ class _OpenBreakerRedis:
lambda cache: cache.async_increment_cache_pipeline(
increment_list=[RedisPipelineIncrementOperation(key="k", increment_value=1.0, ttl=60)]
),
+ lambda cache: cache.async_increment_cache("k", 1.0),
],
- ids=["get", "batch_get", "set", "set_pipeline", "increment_pipeline"],
+ ids=["get", "batch_get", "set", "set_pipeline", "increment_pipeline", "increment"],
)
async def test_an_open_circuit_breaker_is_not_an_error_per_request(caplog, call):
"""While the breaker is open every request is refused by design, and the breaker already