fix(dual_cache): fall back to L1 instead of re-raising on Redis increment failures

This commit is contained in:
Ishaan Jaffer 2026-03-19 20:07:44 -07:00
parent 0f779650ed
commit 3937f8e282

View file

@ -401,8 +401,8 @@ class DualCache(BaseCache):
Returns - float - the incremented value
"""
result: float = value
try:
result: float = value
if self.in_memory_cache is not None:
result = await self.in_memory_cache.async_increment(
key, value, **kwargs
@ -418,7 +418,11 @@ class DualCache(BaseCache):
return result
except Exception as e:
raise e # don't log if exception is raised
verbose_logger.warning(
"Redis async_increment_cache failed, falling back to in-memory result: %s",
e,
)
return result
async def async_increment_cache_pipeline(
self,
@ -427,8 +431,8 @@ class DualCache(BaseCache):
parent_otel_span: Optional[Span] = None,
**kwargs,
) -> Optional[List[float]]:
result: Optional[List[float]] = None
try:
result: Optional[List[float]] = None
if self.in_memory_cache is not None:
result = await self.in_memory_cache.async_increment_pipeline(
increment_list=increment_list,
@ -443,7 +447,11 @@ class DualCache(BaseCache):
return result
except Exception as e:
raise e # don't log if exception is raised
verbose_logger.warning(
"Redis async_increment_cache_pipeline failed, falling back to in-memory result: %s",
e,
)
return result
async def async_set_cache_sadd(
self, key, value: List, local_only: bool = False, **kwargs