Skip to content

Commit 25ba4b3

Browse files
committed
Merge grace-cache into the framework
Closes gh-1209
2 parents 6e67167 + 566f3d2 commit 25ba4b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2940
-0
lines changed

grace-cache-core/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# grace-cache-core
2+
3+
This module contains Cache annotations and core APIs.

grace-cache-core/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies {
2+
api project(":grace-core")
3+
api libs.spring.aop
4+
api libs.spring.context
5+
api libs.grace.datastore.core
6+
api libs.grace.datastore.gorm, {
7+
exclude group: 'org.graceframework', module: 'grace-datastore-gorm-validation'
8+
}
9+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* Copyright 2012-2013 SpringSource.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package grails.plugin.cache;
16+
17+
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
18+
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
19+
20+
import java.lang.annotation.*;
21+
22+
/**
23+
* Indicates that a method (or all methods on a class) trigger(s)
24+
* a cache invalidate operation.
25+
*
26+
* @author Jeff Brown
27+
* @author Graeme Rocher
28+
*/
29+
@Target({ElementType.METHOD, ElementType.TYPE})
30+
@Retention(RetentionPolicy.RUNTIME)
31+
@Inherited
32+
@Documented
33+
@GroovyASTTransformationClass("org.grails.datastore.gorm.transform.OrderedGormTransformation")
34+
@GormASTTransformationClass("org.grails.plugin.cache.compiler.CacheEvictTransformation")
35+
public @interface CacheEvict {
36+
37+
/**
38+
* Qualifier value for the specified cached operation.
39+
* <p>May be used to determine the target cache (or caches), matching the qualifier
40+
* value.
41+
*/
42+
String[] value();
43+
44+
/**
45+
* A closure for computing the key dynamically.
46+
* <p>Default is null, meaning all method parameters are considered as a key.
47+
*/
48+
Class[] key() default {};
49+
50+
/**
51+
* A closure used for conditioning the method caching.
52+
* <p>Default is null, meaning the method is always cached.
53+
*/
54+
Class[] condition() default {};
55+
56+
/**
57+
* Whether or not all the entries inside the cache(s) are removed or not. By
58+
* default, only the value under the associated key is removed.
59+
* <p>Note that specifying setting this parameter to true and specifying a
60+
* CacheKey is not allowed.
61+
*/
62+
boolean allEntries() default false;
63+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright 2015 original authors.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package grails.plugin.cache;
16+
17+
import java.lang.annotation.ElementType;
18+
import java.lang.annotation.Retention;
19+
import java.lang.annotation.RetentionPolicy;
20+
import java.lang.annotation.Target;
21+
22+
/**
23+
* An annotation added to all methods or types that produce a cache operation.
24+
*
25+
* @author Graeme Rocher
26+
*/
27+
@Target({ElementType.METHOD, ElementType.TYPE})
28+
@Retention(RetentionPolicy.RUNTIME)
29+
public @interface CacheOperation {
30+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* Copyright 2012-2013 SpringSource.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package grails.plugin.cache;
16+
17+
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
18+
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
19+
20+
import java.lang.annotation.*;
21+
22+
/**
23+
* Indicates that a method (or all methods on a class) trigger(s)
24+
* aCache#put(Object, Object) operation. As opposed to {@link Cacheable} annotation,
25+
* this annotation does not cause the target method to be skipped - rather it
26+
* always causes the method to be invoked and its result to be placed into the cache.
27+
*
28+
* @author Jeff Brown
29+
* @author Graeme Rocher
30+
*/
31+
@Target({ ElementType.METHOD, ElementType.TYPE })
32+
@Retention(RetentionPolicy.RUNTIME)
33+
@Inherited
34+
@Documented
35+
@GroovyASTTransformationClass("org.grails.datastore.gorm.transform.OrderedGormTransformation")
36+
@GormASTTransformationClass("org.grails.plugin.cache.compiler.CachePutTransformation")
37+
public @interface CachePut {
38+
39+
/**
40+
* Name of the caches in which the update takes place.
41+
* <p>May be used to determine the target cache (or caches), matching the
42+
* qualifier value.
43+
*/
44+
String[] value();
45+
46+
/**
47+
* A closure for computing the key dynamically.
48+
* <p>Default is null, meaning all method parameters are considered as a key.
49+
*/
50+
Class[] key() default {};
51+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* Copyright 2012-201 SpringSource.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package grails.plugin.cache;
16+
17+
import java.lang.annotation.Documented;
18+
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Inherited;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
25+
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
26+
27+
/**
28+
* Indicates that a method (or all the methods on a class) can be cached.
29+
*
30+
* <p>The method arguments and signature are used for computing the key while the
31+
* returned instance is used as the cache value.
32+
*
33+
* @author Jeff Brown
34+
* @author Graeme Rocher
35+
*/
36+
@Target({ElementType.METHOD, ElementType.TYPE})
37+
@Retention(RetentionPolicy.RUNTIME)
38+
@Inherited
39+
@Documented
40+
@GroovyASTTransformationClass("org.grails.datastore.gorm.transform.OrderedGormTransformation")
41+
@GormASTTransformationClass("org.grails.plugin.cache.compiler.CacheableTransformation")
42+
public @interface Cacheable {
43+
44+
/**
45+
* Name of the caches in which the update takes place.
46+
* <p>May be used to determine the target cache (or caches), matching the
47+
* qualifier value.
48+
*/
49+
String[] value();
50+
51+
/**
52+
* A closure for computing the key dynamically.
53+
* <p>Default is null, meaning all method parameters are considered as a key.
54+
*/
55+
Class[] key() default {};
56+
57+
/**
58+
* A closure used for conditioning the method caching.
59+
* <p>Default is null, meaning the method is always cached.
60+
*/
61+
Class[] condition() default {};
62+
}

0 commit comments

Comments
 (0)