'Spring @Cacheable doesn't retry on error from Jedis/Redis

Spring @Cacheable doesn't retry on error from Jedis/Redis.

We have errors during data read:

org.springframework.dao.InvalidDataAccessApiUsageException: Cluster retry deadline exceeded.; nested exception is redis.clients.jedis.exceptions.JedisClusterOperationException: Cluster retry deadline exceeded.

error is not handled by @Cacheable annotation (i'd expect to get data from annonated method in case of an error)

at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at com.sun.proxy.$Proxy163.findById(Unknown Source:0)

I can see that there is void handleCacheGetError(RuntimeException exception, Cache cache, Object key)

but I don't see any parameters that would help me to retrieve data from original method/source (fallback behaviour)

How to handle it ? It looks like that @Cacheable is not very usable in case of cache errors (Do i need to implement my own bespoke code using RedisTemplate etc. ? )



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source