Package io.micronaut.cache
Interface CacheErrorHandler
-
- All Known Implementing Classes:
AsyncCacheErrorHandler
,DefaultCacheErrorHandler
public interface CacheErrorHandler
An interface for handling cache errors.
- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default boolean
handleInvalidateError(Cache<?> cache, java.lang.Object key, java.lang.RuntimeException e)
Handles a cacheCacheInvalidate
error.default boolean
handleInvalidateError(Cache<?> cache, java.lang.RuntimeException e)
Handles a cacheCacheInvalidate
error.default boolean
handleLoadError(Cache<?> cache, java.lang.Object key, java.lang.RuntimeException e)
Handles an error loading a value from the cache viaCacheable
.default boolean
handlePutError(Cache<?> cache, java.lang.Object key, java.lang.Object result, java.lang.RuntimeException e)
Handles a cacheCachePut
error.
-
-
-
Method Detail
-
handleInvalidateError
default boolean handleInvalidateError(Cache<?> cache, java.lang.Object key, java.lang.RuntimeException e)
Handles a cacheCacheInvalidate
error. Defaults to simply rethrowing the error. By returningfalse
cache invalidate errors will instead to be swallowed and ignored.- Parameters:
cache
- The cachekey
- The keye
- 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, java.lang.RuntimeException e)
Handles a cacheCacheInvalidate
error. Defaults to simply rethrowing the error. By returningfalse
cache invalidate errors will instead to be swallowed and ignored.- Parameters:
cache
- The cachee
- 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, java.lang.Object key, java.lang.Object result, java.lang.RuntimeException e)
Handles a cacheCachePut
error. Defaults to simply rethrowing the error. By returningfalse
cache write errors will instead to be swallowed and ignored.- Parameters:
cache
- The cachekey
- The key nameresult
- The resulte
- 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, java.lang.Object key, java.lang.RuntimeException e)
Handles an error loading a value from the cache viaCacheable
. Note that by returningfalse
the behaviour can be customized such that cache related exceptions are ignored and the original method invoked.- Parameters:
cache
- The cachekey
- The keye
- The error- Returns:
- Whether the exception should be swallowed or rethrown. A value of true will rethrow he exception.
-
-