Skip to content

Commit e0ace00

Browse files
committed
Refactor Grace Cache Core and Plugin
Closes gh-1210
1 parent 25ba4b3 commit e0ace00

File tree

46 files changed

+1656
-1362
lines changed

Some content is hidden

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

46 files changed

+1656
-1362
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package grails.cache;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
26+
27+
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
28+
29+
/**
30+
* Indicates that a method (or all methods on a class) trigger(s)
31+
* a cache invalidate operation.
32+
*
33+
* @author Jeff Brown
34+
* @author Graeme Rocher
35+
* @since 2024.0.0
36+
*/
37+
@Target({ElementType.METHOD, ElementType.TYPE})
38+
@Retention(RetentionPolicy.RUNTIME)
39+
@Inherited
40+
@Documented
41+
@GroovyASTTransformationClass("org.grails.datastore.gorm.transform.OrderedGormTransformation")
42+
@GormASTTransformationClass("org.grails.cache.compiler.CacheEvictTransformation")
43+
public @interface CacheEvict {
44+
45+
/**
46+
* Qualifier value for the specified cached operation.
47+
* <p>May be used to determine the target cache (or caches), matching the qualifier
48+
* value.
49+
*/
50+
String[] value();
51+
52+
/**
53+
* A closure for computing the key dynamically.
54+
* <p>Default is null, meaning all method parameters are considered as a key.
55+
*/
56+
Class[] key() default {};
57+
58+
/**
59+
* A closure used for conditioning the method caching.
60+
* <p>Default is null, meaning the method is always cached.
61+
*/
62+
Class[] condition() default {};
63+
64+
/**
65+
* Weather or not all the entries inside the cache(s) are removed or not. By
66+
* default, only the value under the associated key is removed.
67+
* <p>Note that specifying setting this parameter to true and specifying a
68+
* CacheKey is not allowed.
69+
*/
70+
boolean allEntries() default false;
71+
}

grace-cache-core/src/main/groovy/grails/plugin/cache/CacheOperation.java renamed to grace-cache-core/src/main/groovy/grails/cache/CacheOperation.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
/* Copyright 2015 original authors.
1+
/*
2+
* Copyright 2015-2025 the original author or authors.
23
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
56
* You may obtain a copy of the License at
67
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
89
*
910
* Unless required by applicable law or agreed to in writing, software
1011
* distributed under the License is distributed on an "AS IS" BASIS,
1112
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
* See the License for the specific language governing permissions and
1314
* limitations under the License.
1415
*/
15-
package grails.plugin.cache;
16+
package grails.cache;
1617

1718
import java.lang.annotation.ElementType;
1819
import java.lang.annotation.Retention;
@@ -23,6 +24,7 @@
2324
* An annotation added to all methods or types that produce a cache operation.
2425
*
2526
* @author Graeme Rocher
27+
* @since 2024.0.0
2628
*/
2729
@Target({ElementType.METHOD, ElementType.TYPE})
2830
@Retention(RetentionPolicy.RUNTIME)

grace-cache-core/src/main/groovy/grails/plugin/cache/CachePut.java renamed to grace-cache-core/src/main/groovy/grails/cache/CachePut.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
/* Copyright 2012-2013 SpringSource.
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
23
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
56
* You may obtain a copy of the License at
67
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
89
*
910
* Unless required by applicable law or agreed to in writing, software
1011
* distributed under the License is distributed on an "AS IS" BASIS,
1112
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
* See the License for the specific language governing permissions and
1314
* limitations under the License.
1415
*/
15-
package grails.plugin.cache;
16+
package grails.cache;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
1624

1725
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
18-
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
1926

20-
import java.lang.annotation.*;
27+
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
2128

2229
/**
2330
* Indicates that a method (or all methods on a class) trigger(s)
@@ -27,25 +34,27 @@
2734
*
2835
* @author Jeff Brown
2936
* @author Graeme Rocher
37+
* @since 2024.0.0
3038
*/
31-
@Target({ ElementType.METHOD, ElementType.TYPE })
39+
@Target({ElementType.METHOD, ElementType.TYPE})
3240
@Retention(RetentionPolicy.RUNTIME)
3341
@Inherited
3442
@Documented
3543
@GroovyASTTransformationClass("org.grails.datastore.gorm.transform.OrderedGormTransformation")
36-
@GormASTTransformationClass("org.grails.plugin.cache.compiler.CachePutTransformation")
44+
@GormASTTransformationClass("org.grails.cache.compiler.CachePutTransformation")
3745
public @interface CachePut {
3846

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();
47+
/**
48+
* Name of the caches in which the update takes place.
49+
* <p>May be used to determine the target cache (or caches), matching the
50+
* qualifier value.
51+
*/
52+
String[] value();
53+
54+
/**
55+
* A closure for computing the key dynamically.
56+
* <p>Default is null, meaning all method parameters are considered as a key.
57+
*/
58+
Class[] key() default {};
4559

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 {};
5160
}

grace-cache-core/src/main/groovy/grails/plugin/cache/Cacheable.java renamed to grace-cache-core/src/main/groovy/grails/cache/Cacheable.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
/* Copyright 2012-201 SpringSource.
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
23
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
56
* You may obtain a copy of the License at
67
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
89
*
910
* Unless required by applicable law or agreed to in writing, software
1011
* distributed under the License is distributed on an "AS IS" BASIS,
1112
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
* See the License for the specific language governing permissions and
1314
* limitations under the License.
1415
*/
15-
package grails.plugin.cache;
16+
package grails.cache;
1617

1718
import java.lang.annotation.Documented;
1819
import java.lang.annotation.ElementType;
@@ -22,6 +23,7 @@
2223
import java.lang.annotation.Target;
2324

2425
import org.codehaus.groovy.transform.GroovyASTTransformationClass;
26+
2527
import org.grails.datastore.gorm.transform.GormASTTransformationClass;
2628

2729
/**
@@ -32,13 +34,14 @@
3234
*
3335
* @author Jeff Brown
3436
* @author Graeme Rocher
37+
* @since 2024.0.0
3538
*/
3639
@Target({ElementType.METHOD, ElementType.TYPE})
3740
@Retention(RetentionPolicy.RUNTIME)
3841
@Inherited
3942
@Documented
4043
@GroovyASTTransformationClass("org.grails.datastore.gorm.transform.OrderedGormTransformation")
41-
@GormASTTransformationClass("org.grails.plugin.cache.compiler.CacheableTransformation")
44+
@GormASTTransformationClass("org.grails.cache.compiler.CacheableTransformation")
4245
public @interface Cacheable {
4346

4447
/**
@@ -59,4 +62,5 @@
5962
* <p>Default is null, meaning the method is always cached.
6063
*/
6164
Class[] condition() default {};
65+
6266
}

0 commit comments

Comments
 (0)