当前位置: 首页>>代码示例>>Java>>正文


Java CachingConfigurer类代码示例

本文整理汇总了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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:22,代码来源:ElastiCacheAutoConfigurationTest.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:ElastiCacheAutoConfigurationTest.java

示例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));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:ElastiCacheCachingConfigurationTest.java

示例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));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:ElastiCacheCachingConfigurationTest.java

示例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));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:ElastiCacheCachingConfigurationTest.java

示例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();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:AbstractJCacheConfiguration.java

示例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);
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:12,代码来源:ElastiCacheCachingConfiguration.java

示例8: simpleCachingConfigurer

import org.springframework.cache.annotation.CachingConfigurer; //导入依赖的package包/类
@Bean
public CachingConfigurer simpleCachingConfigurer(){
	return new SimpleCachingConfigurer();
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:5,代码来源:SpringCacheConfiguration.java


注:本文中的org.springframework.cache.annotation.CachingConfigurer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。