use of org.springframework.cache.caffeine.CaffeineCache in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method validateCaffeineCacheWithStats.
private void validateCaffeineCacheWithStats() {
CaffeineCacheManager cacheManager = validateCacheManager(CaffeineCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
Cache foo = cacheManager.getCache("foo");
foo.get("1");
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(1L);
}
use of org.springframework.cache.caffeine.CaffeineCache in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method caffeineCacheWithExplicitCaches.
@Test
public void caffeineCacheWithExplicitCaches() {
load(DefaultCacheConfiguration.class, "spring.cache.type=caffeine", "spring.cache.cacheNames=foo");
CaffeineCacheManager cacheManager = validateCacheManager(CaffeineCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo");
Cache foo = cacheManager.getCache("foo");
foo.get("1");
// See next tests: no spec given so stats should be disabled
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(0L);
}
use of org.springframework.cache.caffeine.CaffeineCache in project thingsboard by thingsboard.
the class CaffeineCacheConfiguration method cacheManager.
@Bean
public CacheManager cacheManager() {
SimpleCacheManager manager = new SimpleCacheManager();
if (specs != null) {
List<CaffeineCache> caches = specs.entrySet().stream().map(entry -> buildCache(entry.getKey(), entry.getValue())).collect(Collectors.toList());
manager.setCaches(caches);
}
return manager;
}
use of org.springframework.cache.caffeine.CaffeineCache in project faf-java-server by FAForever.
the class CacheConfig method cacheManager.
@Bean
public CacheManager cacheManager() {
SimpleCacheManager cacheManager = new SimpleCacheManager();
cacheManager.setCaches(Arrays.asList(new CaffeineCache(CacheNames.FEATURED_MODS, newBuilder().expireAfterWrite(5, MINUTES).build()), new CaffeineCache(CacheNames.RANKED_MODS, newBuilder().expireAfterWrite(5, MINUTES).build()), new CaffeineCache(CacheNames.MAP_VERSIONS, newBuilder().expireAfterAccess(5, MINUTES).build())));
return cacheManager;
}
use of org.springframework.cache.caffeine.CaffeineCache in project commons-dao by reportportal.
the class CacheConfiguration method getGlobalCacheManager.
/**
* Global Cache Manager
*/
@Bean
public CacheManager getGlobalCacheManager() {
SimpleCacheManager cacheManager = new SimpleCacheManager();
// @formatter:off
CaffeineCache tickets = new CaffeineCache(EXTERNAL_SYSTEM_TICKET_CACHE, Caffeine.newBuilder().maximumSize(ticketCacheSize).softValues().expireAfterAccess(ticketCacheExpiration, TimeUnit.MINUTES).build());
CaffeineCache projects = new CaffeineCache(JIRA_PROJECT_CACHE, Caffeine.newBuilder().maximumSize(projectCacheSize).softValues().expireAfterAccess(projectCacheExpiration, TimeUnit.DAYS).build());
CaffeineCache projectInfo = new CaffeineCache(PROJECT_INFO_CACHE, Caffeine.newBuilder().maximumSize(projectCacheSize).softValues().expireAfterWrite(projectInfoCacheExpiration, TimeUnit.MINUTES).build());
cacheManager.setCaches(ImmutableList.<Cache>builder().add(tickets).add(projects).add(projectInfo).build());
return cacheManager;
}
Aggregations