Whenever I build up a spring boot application, I should register a custom CacheErrorHandler to prevent failing a request when a remote cache is not available. I think it is a common case by developers.

LoggingCacheErrorHandler is added in spring framework 5.3.16. If spring boot registers LoggingCacheErrorHandler as bean, It will be very convenient.

Thank you.

Comment From: mhalbritter

The default handler which Spring uses if none is configured is the SimpleCacheErrorHandler, which throws the exception back to the caller.

The LoggingCacheErrorHandler, which you mentioned, logs the error message and treats the cache get as a cache miss in case of an exception.

I think throwing the exception back to the caller in case of a cache failure is a sensible default, which should not be changed.

Comment From: mgagp

A cache is supposed to improve performance when possible and let the code do its jobs otherwise. If a cache is not there, the application must work as if there was a cache miss.

Comment From: mhalbritter

And if you want that, it's as easy as this:

@Component
class MyCachingConfigurer implements CachingConfigurer {

    @Override
    public CacheErrorHandler errorHandler() {
        return new LoggingCacheErrorHandler();
    }

}