spring mvc - How to disable Redis Caching at run time if redis connection failed - Stack Overflow
So, I was digging through the core Spring Framework Caching Abstraction source today addressing another question and it seems if a CacheErrorHandler is implemented properly, then perhaps a problematic Redis Connection could still result in the desired behavior, e.g. cache "miss" (triggered with the return of a null value).
See the AbstractCacheInvoker source for more details.
The cache.get(key)
should result in an exception due to a faulty Redis Connection and thus Exception handler would be invoked...
catch (RuntimeException e) { getErrorHandler().handleCacheGetError(e, cache, key); return null; // If the exception is handled, return a cache miss }
If the CacheErrorHandler properly handles the Cache "get" error (and does not re-throw the/an Exception), then a null value will be returned indicating a cache "miss".
Read full article from spring mvc - How to disable Redis Caching at run time if redis connection failed - Stack Overflow
No comments:
Post a Comment