use of org.springframework.cache.caffeine.CaffeineCacheManager 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.CaffeineCacheManager 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.CaffeineCacheManager in project spring-boot by spring-projects.
the class CaffeineCacheConfiguration method cacheManager.
@Bean
public CaffeineCacheManager cacheManager() {
CaffeineCacheManager cacheManager = createCacheManager();
List<String> cacheNames = this.cacheProperties.getCacheNames();
if (!CollectionUtils.isEmpty(cacheNames)) {
cacheManager.setCacheNames(cacheNames);
}
return this.customizers.customize(cacheManager);
}
use of org.springframework.cache.caffeine.CaffeineCacheManager in project spring-boot by spring-projects.
the class CaffeineCacheConfiguration method createCacheManager.
private CaffeineCacheManager createCacheManager() {
CaffeineCacheManager cacheManager = new CaffeineCacheManager();
setCacheBuilder(cacheManager);
if (this.cacheLoader != null) {
cacheManager.setCacheLoader(this.cacheLoader);
}
return cacheManager;
}
Aggregations