本文整理汇总了Java中org.springframework.cache.annotation.CachingConfigurer类的典型用法代码示例。如果您正苦于以下问题:Java CachingConfigurer类的具体用法?Java CachingConfigurer怎么用?Java CachingConfigurer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CachingConfigurer类属于org.springframework.cache.annotation包,在下文中一共展示了CachingConfigurer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cacheManager_configuredMultipleCachesWithStack_configuresCacheManager
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Test
public void cacheManager_configuredMultipleCachesWithStack_configuresCacheManager() throws Exception {
//Arrange
HttpServer httpServer = MetaDataServer.setupHttpServer();
HttpContext instanceIdHttpContext = httpServer.createContext("/latest/meta-data/instance-id", new MetaDataServer.HttpResponseWriterHandler("testInstanceId"));
this.context = new AnnotationConfigApplicationContext();
this.context.register(MockCacheConfigurationWithStackCaches.class);
this.context.register(ElastiCacheAutoConfiguration.class);
//Act
this.context.refresh();
//Assert
CacheManager cacheManager = this.context.getBean(CachingConfigurer.class).cacheManager();
assertTrue(cacheManager.getCacheNames().contains("sampleCacheOneLogical"));
assertTrue(cacheManager.getCacheNames().contains("sampleCacheTwoLogical"));
assertEquals(2, cacheManager.getCacheNames().size());
httpServer.removeContext(instanceIdHttpContext);
}
示例2: cacheManager_configuredNoCachesWithNoStack_configuresNoCacheManager
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Test
public void cacheManager_configuredNoCachesWithNoStack_configuresNoCacheManager() throws Exception {
//Arrange
HttpServer httpServer = MetaDataServer.setupHttpServer();
HttpContext instanceIdHttpContext = httpServer.createContext("/latest/meta-data/instance-id", new MetaDataServer.HttpResponseWriterHandler("testInstanceId"));
this.context = new AnnotationConfigApplicationContext();
this.context.register(ElastiCacheAutoConfiguration.class);
//Act
this.context.refresh();
//Assert
CacheManager cacheManager = this.context.getBean(CachingConfigurer.class).cacheManager();
assertEquals(0, cacheManager.getCacheNames().size());
httpServer.removeContext(instanceIdHttpContext);
}
示例3: enableElasticache_configuredWithExplicitCluster_configuresExplicitlyConfiguredCaches
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Test
public void enableElasticache_configuredWithExplicitCluster_configuresExplicitlyConfiguredCaches() throws Exception {
//Arrange
//Act
this.context = new AnnotationConfigApplicationContext(ApplicationConfigurationWithExplicitStackConfiguration.class);
//Assert
CacheManager cacheManager = this.context.getBean(CachingConfigurer.class).cacheManager();
assertEquals(2, cacheManager.getCacheNames().size());
Cache firstCache = cacheManager.getCache("firstCache");
assertNotNull(firstCache.getName());
assertEquals(0, getExpirationFromCache(firstCache));
Cache secondCache = cacheManager.getCache("secondCache");
assertNotNull(secondCache.getName());
assertEquals(0, getExpirationFromCache(secondCache));
}
示例4: AnnotationConfigApplicationContext
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Test
public void enableElasticache_configuredWithExplicitClusterAndExpiration_configuresExplicitlyConfiguredCachesWithCustomExpirationTimes() throws Exception {
//Arrange
//Act
this.context = new AnnotationConfigApplicationContext(ApplicationConfigurationWithExplicitStackConfigurationAndExpiryTime.class);
//Assert
CacheManager cacheManager = this.context.getBean(CachingConfigurer.class).cacheManager();
assertEquals(2, cacheManager.getCacheNames().size());
Cache firstCache = cacheManager.getCache("firstCache");
assertNotNull(firstCache.getName());
assertEquals(23, getExpirationFromCache(firstCache));
Cache secondCache = cacheManager.getCache("secondCache");
assertNotNull(secondCache.getName());
assertEquals(42, getExpirationFromCache(secondCache));
}
示例5: enableElasticache_configuredWithoutExplicitCluster_configuresImplicitlyConfiguredCaches
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Test
public void enableElasticache_configuredWithoutExplicitCluster_configuresImplicitlyConfiguredCaches() throws Exception {
//Arrange
//Act
this.context = new AnnotationConfigApplicationContext(ApplicationConfigurationWithNoExplicitStackConfiguration.class);
//Assert
CacheManager cacheManager = this.context.getBean(CachingConfigurer.class).cacheManager();
assertEquals(2, cacheManager.getCacheNames().size());
Cache firstCache = cacheManager.getCache("sampleCacheOneLogical");
assertNotNull(firstCache.getName());
assertEquals(0, getExpirationFromCache(firstCache));
Cache secondCache = cacheManager.getCache("sampleCacheTwoLogical");
assertNotNull(secondCache.getName());
assertEquals(0, getExpirationFromCache(secondCache));
}
示例6: useCachingConfigurer
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Override
protected void useCachingConfigurer(CachingConfigurer config) {
super.useCachingConfigurer(config);
if (config instanceof JCacheConfigurer) {
this.exceptionCacheResolver = ((JCacheConfigurer) config).exceptionCacheResolver();
}
}
示例7: cachingConfigurer
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Bean
public CachingConfigurer cachingConfigurer(AmazonElastiCache amazonElastiCache, ResourceIdResolver resourceIdResolver,
List<CacheFactory> cacheFactories) {
if (this.annotationAttributes != null && this.annotationAttributes.getAnnotationArray("value").length > 0) {
return new ElastiCacheCacheConfigurer(amazonElastiCache, resourceIdResolver,
getCacheNamesFromCacheClusterConfigs(this.annotationAttributes.getAnnotationArray("value")), cacheFactories);
} else {
return new ElastiCacheCacheConfigurer(amazonElastiCache, resourceIdResolver,
getConfiguredCachesInStack(), cacheFactories);
}
}
示例8: simpleCachingConfigurer
import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Bean
public CachingConfigurer simpleCachingConfigurer(){
return new SimpleCachingConfigurer();
}