Interface CacheErrorHandler

All Known Implementing Classes:
AsyncCacheErrorHandler, DefaultCacheErrorHandler

public interface CacheErrorHandler

An interface for handling cache errors.

Since:
1.0
Author:
Graeme Rocher
  • Method Details

    • handleInvalidateError

      default boolean handleInvalidateError(Cache<?> cache, Object key, RuntimeException e)
      Handles a cache CacheInvalidate error. Defaults to simply rethrowing the error. By returning false cache invalidate errors will instead to be swallowed and ignored.
      Parameters:
      cache - The cache
      key - The key
      e - The error
      Returns:
      Whether the exception should be swallowed or rethrown. A value of true will rethrow he exception.
    • handleInvalidateError

      default boolean handleInvalidateError(Cache<?> cache, RuntimeException e)
      Handles a cache CacheInvalidate error. Defaults to simply rethrowing the error. By returning false cache invalidate errors will instead to be swallowed and ignored.
      Parameters:
      cache - The cache
      e - The error
      Returns:
      Whether the exception should be swallowed or rethrown. A value of true will rethrow he exception.
    • handlePutError

      default boolean handlePutError(Cache<?> cache, Object key, Object result, RuntimeException e)
      Handles a cache CachePut error. Defaults to simply rethrowing the error. By returning false cache write errors will instead to be swallowed and ignored.
      Parameters:
      cache - The cache
      key - The key name
      result - The result
      e - The error
      Returns:
      Whether the exception should be swallowed or rethrown. A value of true will rethrow he exception.
    • handleLoadError

      default boolean handleLoadError(Cache<?> cache, Object key, RuntimeException e)
      Handles an error loading a value from the cache via Cacheable. Note that by returning false the behaviour can be customized such that cache related exceptions are ignored and the original method invoked.
      Parameters:
      cache - The cache
      key - The key
      e - The error
      Returns:
      Whether the exception should be swallowed or rethrown. A value of true will rethrow he exception.