use of org.springframework.cache.CacheManager in project spring-boot by spring-projects.
the class CachePublicMetrics method addMetrics.
private void addMetrics(Collection<Metric<?>> metrics, String cacheName, List<CacheManagerBean> cacheManagerBeans) {
for (CacheManagerBean cacheManagerBean : cacheManagerBeans) {
CacheManager cacheManager = cacheManagerBean.getCacheManager();
Cache cache = cacheManager.getCache(cacheName);
CacheStatistics statistics = getCacheStatistics(cache, cacheManager);
if (statistics != null) {
String prefix = cacheName;
if (cacheManagerBeans.size() > 1) {
prefix = cacheManagerBean.getBeanName() + "_" + prefix;
}
prefix = "cache." + prefix + (prefix.endsWith(".") ? "" : ".");
metrics.addAll(statistics.toMetrics(prefix));
}
}
}
use of org.springframework.cache.CacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method testCustomizers.
@SuppressWarnings("rawtypes")
private void testCustomizers(Class<?> config, String cacheType, String... expectedCustomizerNames) {
load(config, "spring.cache.type=" + cacheType);
CacheManager cacheManager = validateCacheManager(CacheManager.class);
List<String> expected = new ArrayList<>();
expected.addAll(Arrays.asList(expectedCustomizerNames));
Map<String, CacheManagerTestCustomizer> map = this.context.getBeansOfType(CacheManagerTestCustomizer.class);
for (Map.Entry<String, CacheManagerTestCustomizer> entry : map.entrySet()) {
if (expected.contains(entry.getKey())) {
expected.remove(entry.getKey());
assertThat(entry.getValue().cacheManager).isSameAs(cacheManager);
} else {
assertThat(entry.getValue().cacheManager).isNull();
}
}
assertThat(expected).hasSize(0);
}
use of org.springframework.cache.CacheManager 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.CacheManager in project tutorials by eugenp.
the class CacheConfiguration method cacheManager.
@Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
log.debug("Starting HazelcastCacheManager");
CacheManager cacheManager = new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
return cacheManager;
}
use of org.springframework.cache.CacheManager in project tutorials by eugenp.
the class CacheConfiguration method cacheManager.
@Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
log.debug("Starting HazelcastCacheManager");
CacheManager cacheManager = new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
return cacheManager;
}
Aggregations