Package io.micronaut.cache
Interface CacheErrorHandler
- All Known Implementing Classes:
AsyncCacheErrorHandler
,DefaultCacheErrorHandler
public interface CacheErrorHandler
An interface for handling cache errors.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
handleInvalidateError
(Cache<?> cache, Object key, RuntimeException e) Handles a cacheCacheInvalidate
error.default boolean
handleInvalidateError
(Cache<?> cache, RuntimeException e) Handles a cacheCacheInvalidate
error.default boolean
handleLoadError
(Cache<?> cache, Object key, RuntimeException e) Handles an error loading a value from the cache viaCacheable
.default boolean
handlePutError
(Cache<?> cache, Object key, Object result, RuntimeException e) Handles a cacheCachePut
error.
-
Method Details
-
handleInvalidateError
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
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
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
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.
-