use of org.springframework.cache.support.SimpleCacheManager in project spring-framework by spring-projects.
the class CacheTestUtils method createSimpleCacheManager.
/**
* Create a {@link SimpleCacheManager} with the specified cache(s).
* @param cacheNames the names of the caches to create
*/
public static CacheManager createSimpleCacheManager(String... cacheNames) {
SimpleCacheManager result = new SimpleCacheManager();
List<Cache> caches = new ArrayList<>();
for (String cacheName : cacheNames) {
caches.add(new ConcurrentMapCache(cacheName));
}
result.setCaches(caches);
result.afterPropertiesSet();
return result;
}
use of org.springframework.cache.support.SimpleCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method genericCacheWithCaches.
@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);
}
use of org.springframework.cache.support.SimpleCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method genericCacheExplicitWithCaches.
@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);
}
use of org.springframework.cache.support.SimpleCacheManager in project spring-boot by spring-projects.
the class GenericCacheConfiguration method cacheManager.
@Bean
public SimpleCacheManager cacheManager(Collection<Cache> caches) {
SimpleCacheManager cacheManager = new SimpleCacheManager();
cacheManager.setCaches(caches);
return this.customizers.customize(cacheManager);
}
use of org.springframework.cache.support.SimpleCacheManager in project spring-framework by spring-projects.
the class AbstractJCacheTests method createSimpleCacheManager.
protected static CacheManager createSimpleCacheManager(String... cacheNames) {
SimpleCacheManager result = new SimpleCacheManager();
List<Cache> caches = new ArrayList<>();
for (String cacheName : cacheNames) {
caches.add(new ConcurrentMapCache(cacheName));
}
result.setCaches(caches);
result.afterPropertiesSet();
return result;
}
Aggregations