Class LoggingCacheErrorHandler

java.lang.Object
org.springframework.cache.interceptor.LoggingCacheErrorHandler
All Implemented Interfaces:
CacheErrorHandler

public class LoggingCacheErrorHandler extends Object implements CacheErrorHandler
A CacheErrorHandler implementation that logs error message. Can be used when underlying cache errors should be ignored.
Since:
5.3.16
Author:
Adam Ostrožlík, Stephane Nicoll
  • Constructor Details

    • LoggingCacheErrorHandler

      public LoggingCacheErrorHandler(Log logger, boolean logStacktrace)
      Create an instance with the logger to use.
      Parameters:
      logger - the logger to use
      logStacktrace - whether to log stack trace
    • LoggingCacheErrorHandler

      public LoggingCacheErrorHandler()
      Create an instance that does not log stack traces.
  • Method Details

    • handleCacheGetError

      public void handleCacheGetError(RuntimeException exception, Cache cache, Object key)
      Description copied from interface: CacheErrorHandler
      Handle the given runtime exception thrown by the cache provider when retrieving an item with the specified key, possibly rethrowing it as a fatal exception.
      Specified by:
      handleCacheGetError in interface CacheErrorHandler
      Parameters:
      exception - the exception thrown by the cache provider
      cache - the cache
      key - the key used to get the item
      See Also:
    • handleCachePutError

      public void handleCachePutError(RuntimeException exception, Cache cache, Object key, @Nullable Object value)
      Description copied from interface: CacheErrorHandler
      Handle the given runtime exception thrown by the cache provider when updating an item with the specified key and value, possibly rethrowing it as a fatal exception.
      Specified by:
      handleCachePutError in interface CacheErrorHandler
      Parameters:
      exception - the exception thrown by the cache provider
      cache - the cache
      key - the key used to update the item
      value - the value to associate with the key
      See Also:
    • handleCacheEvictError

      public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key)
      Description copied from interface: CacheErrorHandler
      Handle the given runtime exception thrown by the cache provider when clearing an item with the specified key, possibly rethrowing it as a fatal exception.
      Specified by:
      handleCacheEvictError in interface CacheErrorHandler
      Parameters:
      exception - the exception thrown by the cache provider
      cache - the cache
      key - the key used to clear the item
    • handleCacheClearError

      public void handleCacheClearError(RuntimeException exception, Cache cache)
      Description copied from interface: CacheErrorHandler
      Handle the given runtime exception thrown by the cache provider when clearing the specified Cache, possibly rethrowing it as a fatal exception.
      Specified by:
      handleCacheClearError in interface CacheErrorHandler
      Parameters:
      exception - the exception thrown by the cache provider
      cache - the cache to clear
    • logCacheError

      protected void logCacheError(Log logger, String message, RuntimeException ex)
      Log the specified message.
      Parameters:
      logger - the logger
      message - the message
      ex - the exception