本文整理汇总了Java中org.springframework.cache.support.SimpleCacheManager类的典型用法代码示例。如果您正苦于以下问题:Java SimpleCacheManager类的具体用法?Java SimpleCacheManager怎么用?Java SimpleCacheManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleCacheManager类属于org.springframework.cache.support包,在下文中一共展示了SimpleCacheManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: genericCacheWithCaches
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Test
public void genericCacheWithCaches() {
load(GenericCacheConfiguration.class);
SimpleCacheManager cacheManager = validateCacheManager(SimpleCacheManager.class);
assertThat(cacheManager.getCache("first"))
.isEqualTo(this.context.getBean("firstCache"));
assertThat(cacheManager.getCache("second"))
.isEqualTo(this.context.getBean("secondCache"));
assertThat(cacheManager.getCacheNames()).hasSize(2);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:CacheAutoConfigurationTests.java
示例2: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
SimpleCacheManager mgr = new SimpleCacheManager();
ArrayList<Cache> caches = new ArrayList<Cache>();
caches.add(new ConcurrentMapCache(""));
mgr.setCaches(caches);
return mgr;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:EnableTransactionManagementIntegrationTests.java
示例3: createSimpleCacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
protected static CacheManager createSimpleCacheManager(String... cacheNames) {
SimpleCacheManager result = new SimpleCacheManager();
List<Cache> caches = new ArrayList<Cache>();
for (String cacheName : cacheNames) {
caches.add(new ConcurrentMapCache(cacheName));
}
result.setCaches(caches);
result.afterPropertiesSet();
return result;
}
示例4: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
SimpleCacheManager cm = new SimpleCacheManager();
cm.setCaches(Arrays.asList(
defaultCache(),
new ConcurrentMapCache("primary"),
new ConcurrentMapCache("secondary"),
new ConcurrentMapCache("exception")));
return cm;
}
示例5: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
@Override
public CacheManager cacheManager() {
Cache defaultCache = new ConcurrentMapCache("default");
Cache localesCache = new ConcurrentMapCache("locales");
SimpleCacheManager manager = new SimpleCacheManager();
manager.setCaches(Arrays.asList(defaultCache, localesCache));
return manager;
}
示例6: genericCacheExplicitWithCaches
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Test
public void genericCacheExplicitWithCaches() {
load(GenericCacheConfiguration.class, "spring.cache.type=generic");
SimpleCacheManager cacheManager = validateCacheManager(SimpleCacheManager.class);
assertThat(cacheManager.getCache("first"))
.isEqualTo(this.context.getBean("firstCache"));
assertThat(cacheManager.getCache("second"))
.isEqualTo(this.context.getBean("secondCache"));
assertThat(cacheManager.getCacheNames()).hasSize(2);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:CacheAutoConfigurationTests.java
示例7: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
simpleCacheManager.setCaches(Arrays.asList(
buildPostCodeCache(),
buildTemperatureCache(),
buildSharesCache()
));
return simpleCacheManager;
}
示例8: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
/**
* 个性化配置缓存
*/
@Bean
public CacheManager cacheManager() {
SimpleCacheManager manager = new SimpleCacheManager();
//把各个cache注册到cacheManager中,CaffeineCache实现了org.springframework.cache.Cache接口
ArrayList<CaffeineCache> caches = new ArrayList<>();
for (Caches c : Caches.values()) {
caches.add(new CaffeineCache(c.name(),
Caffeine.newBuilder().recordStats()
.expireAfterWrite(c.getTtl(), TimeUnit.SECONDS)
.maximumSize(c.getMaxSize())
.build())
);
}
manager.setCaches(caches);
return manager;
}
示例9: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
/**
* 个性化配置缓存
*/
@Bean
public CacheManager cacheManager() {
SimpleCacheManager manager = new SimpleCacheManager();
//把各个cache注册到cacheManager中,GuavaCache实现了org.springframework.cache.Cache接口
ArrayList<GuavaCache> caches = new ArrayList<>();
for (Caches c : Caches.values()) {
caches.add(new GuavaCache(c.name(), CacheBuilder.newBuilder().recordStats().expireAfterWrite(c.getTtl(), TimeUnit.SECONDS).maximumSize(c.getMaxSize()).build()));
}
manager.setCaches(caches);
return manager;
}
示例10: genericCacheWithCaches
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Test
public void genericCacheWithCaches() {
load(GenericCacheConfiguration.class);
SimpleCacheManager cacheManager = validateCacheManager(SimpleCacheManager.class);
assertThat(cacheManager.getCache("first"),
equalTo(this.context.getBean("firstCache")));
assertThat(cacheManager.getCache("second"),
equalTo(this.context.getBean("secondCache")));
assertThat(cacheManager.getCacheNames(), hasSize(2));
}
示例11: genericCacheExplicitWithCaches
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Test
public void genericCacheExplicitWithCaches() {
load(GenericCacheConfiguration.class, "spring.cache.type=generic");
SimpleCacheManager cacheManager = validateCacheManager(SimpleCacheManager.class);
assertThat(cacheManager.getCache("first"),
equalTo(this.context.getBean("firstCache")));
assertThat(cacheManager.getCache("second"),
equalTo(this.context.getBean("secondCache")));
assertThat(cacheManager.getCacheNames(), hasSize(2));
}
示例12: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
@Override
public CacheManager cacheManager() {
CompositeCacheManager compositeCacheManager = new CompositeCacheManager();
List<CacheManager> cacheManagers = Lists.newArrayList();
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
simpleCacheManager.setCaches(Collections.singletonList(
new ConcurrentMapCache("cache")
));
if (this.couchbaseCacheManager != null) {
cacheManagers.add(this.couchbaseCacheManager);
cacheManagers.add(simpleCacheManager);
}
compositeCacheManager.setCacheManagers(cacheManagers);
compositeCacheManager.setFallbackToNoOpCache(true);
return compositeCacheManager;
}
开发者ID:kbastani,项目名称:spring-cloud-polyglot-persistence-example,代码行数:23,代码来源:CachingConfiguration.java
示例13: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Override
@Bean
public CacheManager cacheManager() {
SimpleCacheManager cm = new SimpleCacheManager();
cm.setCaches(Arrays.asList(
new ConcurrentMapCache("default"),
new ConcurrentMapCache("primary"),
new ConcurrentMapCache("secondary")));
return cm;
}
示例14: cacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
@Override
public CacheManager cacheManager() {
SimpleCacheManager manager = new SimpleCacheManager();
manager.setCaches(asList(
new ConcurrentMapCache("default"),
new ConcurrentMapCache("another"))
);
return manager;
}
示例15: createSimpleCacheManager
import org.springframework.cache.support.SimpleCacheManager; //导入依赖的package包/类
@Bean
@Profile("local")
public CacheManager createSimpleCacheManager() {
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
List<Cache> caches = new ArrayList<>(2);
caches.add(new ConcurrentMapCache("CacheCluster"));
caches.add(new ConcurrentMapCache("GitHubSourceCode"));
simpleCacheManager.setCaches(caches);
return simpleCacheManager;
}