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 booleanhandleInvalidateError(Cache<?> cache, Object key, RuntimeException e) Handles a cacheCacheInvalidateerror.default booleanhandleInvalidateError(Cache<?> cache, RuntimeException e) Handles a cacheCacheInvalidateerror.default booleanhandleLoadError(Cache<?> cache, Object key, RuntimeException e) Handles an error loading a value from the cache viaCacheable.default booleanhandlePutError(Cache<?> cache, Object key, Object result, RuntimeException e) Handles a cacheCachePuterror.
-
Method Details
-
handleInvalidateError
Handles a cacheCacheInvalidateerror. Defaults to simply rethrowing the error. By returningfalsecache 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 cacheCacheInvalidateerror. Defaults to simply rethrowing the error. By returningfalsecache 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 cacheCachePuterror. Defaults to simply rethrowing the error. By returningfalsecache 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 returningfalsethe 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.
-