接口 CachingConfigurer
- 所有已知子接口:
JCacheConfigurer
public interface CachingConfigurer
Interface to be implemented by @Configurationclasses annotated with @EnableCachingthat wish or need to specify explicitly how caches are resolved and how keys are generated for annotation-driven cache management. Consider extendingCachingConfigurerSupport, which provides a stub implementation of all interface methods.See @
EnableCachingfor general examples and context; seecacheManager(),cacheResolver()andkeyGenerator()for detailed instructions.- 从以下版本开始:
- 3.1
- 作者:
- Chris Beams, Stephane Nicoll
- 另请参阅:
EnableCaching,CachingConfigurerSupport
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 CacheManagercacheManager()Return the cache manager bean to use for annotation-driven cache management.CacheResolvercacheResolver()Return theCacheResolverbean to use to resolve regular caches for annotation-driven cache management.CacheErrorHandlererrorHandler()Return theCacheErrorHandlerto use to handle cache-related errors.KeyGeneratorkeyGenerator()Return the key generator bean to use for annotation-driven cache management.
方法详细资料
cacheManager
@Nullable CacheManager 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
@Bean, e.g.@Configuration @EnableCaching public class AppConfig extends CachingConfigurerSupport { @Bean // important! @Override public CacheManager cacheManager() { // configure and return CacheManager instance } // ... }See @EnableCachingfor more complete examples.
cacheResolver
@Nullable CacheResolver 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()and#cacheResolver()are set, the cache manager is ignored.Implementations must explicitly declare
@Bean, e.g.@Configuration @EnableCaching public class AppConfig extends CachingConfigurerSupport { @Bean // important! @Override public CacheResolver cacheResolver() { // configure and return CacheResolver instance } // ... }SeeEnableCachingfor more complete examples.
keyGenerator
@Nullable KeyGenerator keyGenerator()
Return the key generator bean to use for annotation-driven cache management. Implementations must explicitly declare@Bean, e.g.@Configuration @EnableCaching public class AppConfig extends CachingConfigurerSupport { @Bean // important! @Override public KeyGenerator keyGenerator() { // configure and return KeyGenerator instance } // ... }See @EnableCachingfor more complete examples.
errorHandler
@Nullable CacheErrorHandler errorHandler()
Return theCacheErrorHandlerto use to handle cache-related errors.By default,
SimpleCacheErrorHandleris used and simply throws the exception back at the client.Implementations must explicitly declare
@Bean, e.g.@Configuration @EnableCaching public class AppConfig extends CachingConfigurerSupport { @Bean // important! @Override public CacheErrorHandler errorHandler() { // configure and return CacheErrorHandler instance } // ... }See @EnableCachingfor more complete examples.