Interface CachingConfigurer
- All Known Subinterfaces:
JCacheConfigurer
- All Known Implementing Classes:
CachingConfigurerSupport,JCacheConfigurerSupport
Configuration classes annotated with @EnableCaching that wish or need to specify
explicitly how caches are resolved and how keys are generated for annotation-driven
cache management.
See @EnableCaching for general examples and context; see
cacheManager(), cacheResolver(), keyGenerator(), and
errorHandler() for detailed instructions.
NOTE: A CachingConfigurer will get initialized early.
Do not inject common dependencies into autowired fields directly; instead, consider
declaring a lazy ObjectProvider for those.
- Since:
- 3.1
- Author:
- Chris Beams, Stephane Nicoll
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault CacheManagerReturn the cache manager bean to use for annotation-driven cache management.default CacheResolverReturn theCacheResolverbean to use to resolve regular caches for annotation-driven cache management.default CacheErrorHandlerReturn theCacheErrorHandlerto use to handle cache-related errors.default KeyGeneratorReturn the key generator bean to use for annotation-driven cache management.
-
Method Details
-
cacheManager
Return the cache manager bean to use for annotation-driven cache management. A defaultCacheResolverwill be initialized behind the scenes with this cache manager. For more fine-grained management of the cache resolution, consider setting theCacheResolverdirectly.Implementations must explicitly declare
@Beanso that the cache manager participates in the lifecycle of the context, for example,@Configuration @EnableCaching class AppConfig implements CachingConfigurer { @Bean // important! @Override CacheManager cacheManager() { // configure and return CacheManager instance } // ... }See @EnableCachingfor more complete examples. -
cacheResolver
Return theCacheResolverbean to use to resolve regular caches for annotation-driven cache management. This is an alternative and more powerful option of specifying theCacheManagerto use.If both a
cacheManager()andcacheResolver()are set, the cache manager is ignored.Implementations must explicitly declare
@Beanso that the cache resolver participates in the lifecycle of the context, for example,@Configuration @EnableCaching class AppConfig implements CachingConfigurer { @Bean // important! @Override CacheResolver cacheResolver() { // configure and return CacheResolver instance } // ... }SeeEnableCachingfor more complete examples. -
keyGenerator
Return the key generator bean to use for annotation-driven cache management.By default,
SimpleKeyGeneratoris used. See @EnableCachingfor more complete examples. -
errorHandler
Return theCacheErrorHandlerto use to handle cache-related errors.By default,
SimpleCacheErrorHandleris used, which throws the exception back at the client. See @EnableCachingfor more complete examples.
-