use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.
the class SimpleCacheConfiguration method cacheManager.
@Bean
ConcurrentMapCacheManager cacheManager(CacheProperties cacheProperties, CacheManagerCustomizers cacheManagerCustomizers) {
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
List<String> cacheNames = cacheProperties.getCacheNames();
if (!cacheNames.isEmpty()) {
cacheManager.setCacheNames(cacheNames);
}
return cacheManagerCustomizers.customize(cacheManager);
}
use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.
the class CachesEndpointTests method namedCacheWithSeveralCacheManagers.
@Test
void namedCacheWithSeveralCacheManagers() {
Map<String, CacheManager> cacheManagers = new LinkedHashMap<>();
cacheManagers.put("test", new ConcurrentMapCacheManager("b", "dupe-cache"));
cacheManagers.put("another", new ConcurrentMapCacheManager("c", "dupe-cache"));
CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
assertThatExceptionOfType(NonUniqueCacheException.class).isThrownBy(() -> endpoint.cache("dupe-cache", null)).withMessageContaining("dupe-cache").withMessageContaining("test").withMessageContaining("another");
}
use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.
the class CachesEndpointTests method allCachesWithSingleCacheManager.
@Test
void allCachesWithSingleCacheManager() {
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", new ConcurrentMapCacheManager("a", "b")));
Map<String, CacheManagerDescriptor> allDescriptors = endpoint.caches().getCacheManagers();
assertThat(allDescriptors).containsOnlyKeys("test");
CacheManagerDescriptor descriptors = allDescriptors.get("test");
assertThat(descriptors.getCaches()).containsOnlyKeys("a", "b");
assertThat(descriptors.getCaches().get("a").getTarget()).isEqualTo(ConcurrentHashMap.class.getName());
assertThat(descriptors.getCaches().get("b").getTarget()).isEqualTo(ConcurrentHashMap.class.getName());
}
use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.
the class CachesEndpointTests method allCachesWithSeveralCacheManagers.
@Test
void allCachesWithSeveralCacheManagers() {
Map<String, CacheManager> cacheManagers = new LinkedHashMap<>();
cacheManagers.put("test", new ConcurrentMapCacheManager("a", "b"));
cacheManagers.put("another", new ConcurrentMapCacheManager("a", "c"));
CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
Map<String, CacheManagerDescriptor> allDescriptors = endpoint.caches().getCacheManagers();
assertThat(allDescriptors).containsOnlyKeys("test", "another");
assertThat(allDescriptors.get("test").getCaches()).containsOnlyKeys("a", "b");
assertThat(allDescriptors.get("another").getCaches()).containsOnlyKeys("a", "c");
}
use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.
the class CachesEndpointTests method namedCacheWithUnknownCache.
@Test
void namedCacheWithUnknownCache() {
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", new ConcurrentMapCacheManager("b", "a")));
CacheEntry entry = endpoint.cache("unknown", null);
assertThat(entry).isNull();
}
Aggregations