Search in sources :

Example 1 with CacheableOperation

use of cn.taketoday.cache.interceptor.CacheableOperation in project today-infrastructure by TAKETODAY.

the class AnnotationCacheOperationSourceTests method cacheAnnotationOverride.

@Test
public void cacheAnnotationOverride() {
    Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
    assertThat(ops.size()).isSameAs(1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertThat(cacheOperation instanceof CacheableOperation).isTrue();
}
Also used : CacheOperation(cn.taketoday.cache.interceptor.CacheOperation) CacheableOperation(cn.taketoday.cache.interceptor.CacheableOperation) Test(org.junit.jupiter.api.Test)

Example 2 with CacheableOperation

use of cn.taketoday.cache.interceptor.CacheableOperation in project today-framework by TAKETODAY.

the class AnnotationCacheOperationSourceTests method cacheAnnotationOverride.

@Test
public void cacheAnnotationOverride() {
    Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
    assertThat(ops.size()).isSameAs(1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertThat(cacheOperation instanceof CacheableOperation).isTrue();
}
Also used : CacheOperation(cn.taketoday.cache.interceptor.CacheOperation) CacheableOperation(cn.taketoday.cache.interceptor.CacheableOperation) Test(org.junit.jupiter.api.Test)

Example 3 with CacheableOperation

use of cn.taketoday.cache.interceptor.CacheableOperation in project today-framework by TAKETODAY.

the class AnnotationCacheOperationSourceTests method multipleStereotypes.

@Test
public void multipleStereotypes() {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleStereotype", 3);
    Iterator<CacheOperation> it = ops.iterator();
    assertThat(it.next() instanceof CacheableOperation).isTrue();
    CacheOperation next = it.next();
    assertThat(next instanceof CacheEvictOperation).isTrue();
    assertThat(next.getCacheNames().contains("foo")).isTrue();
    next = it.next();
    assertThat(next instanceof CacheEvictOperation).isTrue();
    assertThat(next.getCacheNames().contains("bar")).isTrue();
}
Also used : CacheEvictOperation(cn.taketoday.cache.interceptor.CacheEvictOperation) CacheOperation(cn.taketoday.cache.interceptor.CacheOperation) CacheableOperation(cn.taketoday.cache.interceptor.CacheableOperation) Test(org.junit.jupiter.api.Test)

Example 4 with CacheableOperation

use of cn.taketoday.cache.interceptor.CacheableOperation in project today-framework by TAKETODAY.

the class DefaultCacheAnnotationParser method parseCacheableAnnotation.

private CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {
    CacheableOperation.Builder builder = new CacheableOperation.Builder();
    builder.setName(ae.toString());
    builder.setCacheNames(cacheable.cacheNames());
    builder.setCondition(cacheable.condition());
    builder.setUnless(cacheable.unless());
    builder.setKey(cacheable.key());
    builder.setKeyGenerator(cacheable.keyGenerator());
    builder.setCacheManager(cacheable.cacheManager());
    builder.setCacheResolver(cacheable.cacheResolver());
    builder.setSync(cacheable.sync());
    defaultConfig.applyDefault(builder);
    CacheableOperation op = builder.build();
    validateCacheOperation(ae, op);
    return op;
}
Also used : CacheableOperation(cn.taketoday.cache.interceptor.CacheableOperation)

Example 5 with CacheableOperation

use of cn.taketoday.cache.interceptor.CacheableOperation in project today-infrastructure by TAKETODAY.

the class DefaultCacheAnnotationParser method parseCacheableAnnotation.

private CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {
    CacheableOperation.Builder builder = new CacheableOperation.Builder();
    builder.setName(ae.toString());
    builder.setCacheNames(cacheable.cacheNames());
    builder.setCondition(cacheable.condition());
    builder.setUnless(cacheable.unless());
    builder.setKey(cacheable.key());
    builder.setKeyGenerator(cacheable.keyGenerator());
    builder.setCacheManager(cacheable.cacheManager());
    builder.setCacheResolver(cacheable.cacheResolver());
    builder.setSync(cacheable.sync());
    defaultConfig.applyDefault(builder);
    CacheableOperation op = builder.build();
    validateCacheOperation(ae, op);
    return op;
}
Also used : CacheableOperation(cn.taketoday.cache.interceptor.CacheableOperation)

Aggregations

CacheableOperation (cn.taketoday.cache.interceptor.CacheableOperation)6 CacheOperation (cn.taketoday.cache.interceptor.CacheOperation)4 Test (org.junit.jupiter.api.Test)4 CacheEvictOperation (cn.taketoday.cache.interceptor.CacheEvictOperation)2