SPR-8015
+ update default key generator strategy to improve compatibility for implicit declaration on one arg method + updated docs
This commit is contained in:
@@ -77,6 +77,21 @@ public abstract class AbstractAnnotationTest {
|
||||
assertSame(r3, r4);
|
||||
}
|
||||
|
||||
public void testInvalidateWKey(CacheableService service) throws Exception {
|
||||
Object o1 = new Object();
|
||||
Object o2 = new Object();
|
||||
|
||||
Object r1 = service.cache(o1);
|
||||
Object r2 = service.cache(o1);
|
||||
|
||||
assertSame(r1, r2);
|
||||
service.invalidate(o1, null);
|
||||
Object r3 = service.cache(o1);
|
||||
Object r4 = service.cache(o1);
|
||||
assertNotSame(r1, r3);
|
||||
assertSame(r3, r4);
|
||||
}
|
||||
|
||||
public void testConditionalExpression(CacheableService service)
|
||||
throws Exception {
|
||||
Object r1 = service.conditional(4);
|
||||
@@ -132,6 +147,11 @@ public abstract class AbstractAnnotationTest {
|
||||
testInvalidate(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidateWithKey() throws Exception {
|
||||
testInvalidateWKey(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalExpression() throws Exception {
|
||||
testConditionalExpression(cs);
|
||||
@@ -152,6 +172,11 @@ public abstract class AbstractAnnotationTest {
|
||||
testInvalidate(ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassCacheInvalidateWKey() throws Exception {
|
||||
testInvalidateWKey(ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullValue() throws Exception {
|
||||
testNullValue(cs);
|
||||
|
||||
@@ -42,6 +42,10 @@ public class AnnotatedClassCacheableService implements CacheableService {
|
||||
public void invalidate(Object arg1) {
|
||||
}
|
||||
|
||||
@CacheEvict(value = "default", key = "#p0")
|
||||
public void invalidate(Object arg1, Object arg2) {
|
||||
}
|
||||
|
||||
@Cacheable(value = "default", key = "#p0")
|
||||
public Object key(Object arg1, Object arg2) {
|
||||
return counter.getAndIncrement();
|
||||
|
||||
@@ -28,6 +28,8 @@ public interface CacheableService<T> {
|
||||
|
||||
void invalidate(Object arg1);
|
||||
|
||||
void invalidate(Object arg1, Object arg2);
|
||||
|
||||
T conditional(int field);
|
||||
|
||||
T key(Object arg1, Object arg2);
|
||||
|
||||
@@ -40,6 +40,10 @@ public class DefaultCacheableService implements CacheableService<Long> {
|
||||
public void invalidate(Object arg1) {
|
||||
}
|
||||
|
||||
@CacheEvict(value = "default", key = "#p0")
|
||||
public void invalidate(Object arg1, Object arg2) {
|
||||
}
|
||||
|
||||
@Cacheable(value = "default", condition = "#classField == 3")
|
||||
public Long conditional(int classField) {
|
||||
return counter.getAndIncrement();
|
||||
|
||||
Reference in New Issue
Block a user