From 1f0a9c5430ce289b7194d1ddb9fae9a0b1148005 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 19 Mar 2026 20:22:41 -0700 Subject: [PATCH] fix(dual_cache): return None fallback when in_memory_cache is absent and Redis fails --- litellm/caching/dual_cache.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litellm/caching/dual_cache.py b/litellm/caching/dual_cache.py index d72ce2a86d1..34ae3638a5b 100644 --- a/litellm/caching/dual_cache.py +++ b/litellm/caching/dual_cache.py @@ -393,15 +393,16 @@ class DualCache(BaseCache): parent_otel_span: Optional[Span] = None, local_only: bool = False, **kwargs, - ) -> float: + ) -> Optional[float]: """ Key - the key in cache Value - float - the value you want to increment by - Returns - float - the incremented value + Returns - the incremented value, or None if no cache backend is + available (in_memory_cache is None and Redis failed/is absent). """ - result: float = value + result: Optional[float] = None try: if self.in_memory_cache is not None: result = await self.in_memory_cache.async_increment(