use of cn.taketoday.cache.CacheManager in project today-infrastructure by TAKETODAY.
the class AbstractCacheAnnotationTests method testCustomCacheManager.
@Test
public void testCustomCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
assertThat(this.cs.customCacheManager(key)).isSameAs(r1);
Cache cache = customCm.getCache("testCache");
assertThat(cache.get(key)).isNotNull();
}
use of cn.taketoday.cache.CacheManager in project today-infrastructure by TAKETODAY.
the class AbstractCacheAnnotationTests method testCustomCacheManager.
@Test
public void testCustomCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
assertThat(this.cs.customCacheManager(key)).isSameAs(r1);
Cache cache = customCm.getCache("testCache");
assertThat(cache.get(key)).isNotNull();
}
use of cn.taketoday.cache.CacheManager in project today-infrastructure by TAKETODAY.
the class AbstractCacheAnnotationTests method testCustomCacheManager.
@Test
public void testCustomCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
assertThat(this.cs.customCacheManager(key)).isSameAs(r1);
Cache cache = customCm.getCache("testCache");
assertThat(cache.get(key)).isNotNull();
}
use of cn.taketoday.cache.CacheManager in project today-infrastructure by TAKETODAY.
the class CacheResolverCustomizationTests method setup.
@BeforeEach
public void setup() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
this.cacheManager = context.getBean("cacheManager", CacheManager.class);
this.anotherCacheManager = context.getBean("anotherCacheManager", CacheManager.class);
this.simpleService = context.getBean(SimpleService.class);
}
use of cn.taketoday.cache.CacheManager in project today-framework by TAKETODAY.
the class AbstractCacheResolver method resolveCaches.
@Override
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
Collection<String> cacheNames = getCacheNames(context);
if (cacheNames == null) {
return Collections.emptyList();
}
ArrayList<Cache> result = new ArrayList<>(cacheNames.size());
CacheManager cacheManager = getCacheManager();
for (String cacheName : cacheNames) {
Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
throw new IllegalArgumentException("Cannot find cache named '" + cacheName + "' for " + context.getOperation());
}
result.add(cache);
}
return result;
}
Aggregations