Search in sources :

Example 1 with CacheEvictOperation

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

the class DefaultCacheAnnotationParser method parseEvictAnnotation.

private CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {
    CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();
    builder.setName(ae.toString());
    builder.setCacheNames(cacheEvict.cacheNames());
    builder.setCondition(cacheEvict.condition());
    builder.setKey(cacheEvict.key());
    builder.setKeyGenerator(cacheEvict.keyGenerator());
    builder.setCacheManager(cacheEvict.cacheManager());
    builder.setCacheResolver(cacheEvict.cacheResolver());
    builder.setCacheWide(cacheEvict.allEntries());
    builder.setBeforeInvocation(cacheEvict.beforeInvocation());
    defaultConfig.applyDefault(builder);
    CacheEvictOperation op = builder.build();
    validateCacheOperation(ae, op);
    return op;
}
Also used : CacheEvictOperation(cn.taketoday.cache.interceptor.CacheEvictOperation)

Example 2 with CacheEvictOperation

use of cn.taketoday.cache.interceptor.CacheEvictOperation 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 3 with CacheEvictOperation

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

the class DefaultCacheAnnotationParser method parseEvictAnnotation.

private CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {
    CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();
    builder.setName(ae.toString());
    builder.setCacheNames(cacheEvict.cacheNames());
    builder.setCondition(cacheEvict.condition());
    builder.setKey(cacheEvict.key());
    builder.setKeyGenerator(cacheEvict.keyGenerator());
    builder.setCacheManager(cacheEvict.cacheManager());
    builder.setCacheResolver(cacheEvict.cacheResolver());
    builder.setCacheWide(cacheEvict.allEntries());
    builder.setBeforeInvocation(cacheEvict.beforeInvocation());
    defaultConfig.applyDefault(builder);
    CacheEvictOperation op = builder.build();
    validateCacheOperation(ae, op);
    return op;
}
Also used : CacheEvictOperation(cn.taketoday.cache.interceptor.CacheEvictOperation)

Example 4 with CacheEvictOperation

use of cn.taketoday.cache.interceptor.CacheEvictOperation in project today-infrastructure 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)

Aggregations

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