fix(dual_cache): return None fallback when in_memory_cache is absent and Redis fails

This commit is contained in:
Ishaan Jaffer 2026-03-19 20:22:41 -07:00
parent ac7fdc389e
commit 1f0a9c5430

View file

@ -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(