From 44e9450403cb229edcbad9b57b3f00a5ed8854bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Thu, 10 Mar 2022 23:41:35 +0100 Subject: [PATCH] Minor code improvements (#106) * Remove unused imports * Fix typos --- .../grails/plugin/cache/CustomCacheKeyGenerator.groovy | 2 -- .../cache/compiler/AbstractCacheTransformation.groovy | 1 - .../plugin/cache/compiler/CacheEvictTransformation.groovy | 4 ---- .../plugin/cache/compiler/CacheableTransformation.groovy | 2 -- src/main/docs/guide/usage/cacheManager.adoc | 2 +- .../com/demo/BasicCachingServiceNoCacheManagerSpec.groovy | 4 ++-- src/test/groovy/com/demo/BasicCachingServiceSpec.groovy | 6 +++--- .../groovy/grails/plugin/cache/CacheableParseSpec.groovy | 1 - 8 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy b/src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy index 3b3a8d77..97ce2f1e 100644 --- a/src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy +++ b/src/ast/groovy/grails/plugin/cache/CustomCacheKeyGenerator.groovy @@ -15,7 +15,6 @@ package grails.plugin.cache import groovy.transform.CompileStatic -import groovy.transform.EqualsAndHashCode import org.springframework.aop.framework.AopProxyUtils import org.springframework.cache.interceptor.KeyGenerator import org.springframework.cache.interceptor.SimpleKeyGenerator @@ -187,4 +186,3 @@ class CustomCacheKeyGenerator implements KeyGenerator, GrailsCacheKeyGenerator { } } - diff --git a/src/ast/groovy/org/grails/plugin/cache/compiler/AbstractCacheTransformation.groovy b/src/ast/groovy/org/grails/plugin/cache/compiler/AbstractCacheTransformation.groovy index 018812de..ddea77f9 100644 --- a/src/ast/groovy/org/grails/plugin/cache/compiler/AbstractCacheTransformation.groovy +++ b/src/ast/groovy/org/grails/plugin/cache/compiler/AbstractCacheTransformation.groovy @@ -11,7 +11,6 @@ import org.codehaus.groovy.ast.stmt.Statement import org.codehaus.groovy.control.SourceUnit import org.codehaus.groovy.transform.trait.TraitComposer import org.grails.datastore.gorm.multitenancy.transform.TenantTransform -import org.grails.datastore.gorm.transactions.transform.TransactionalTransform import org.grails.datastore.gorm.transform.AbstractMethodDecoratingTransformation import org.grails.datastore.gorm.transform.AbstractTraitApplyingGormASTTransformation import org.grails.datastore.mapping.core.Ordered diff --git a/src/ast/groovy/org/grails/plugin/cache/compiler/CacheEvictTransformation.groovy b/src/ast/groovy/org/grails/plugin/cache/compiler/CacheEvictTransformation.groovy index a556351c..17fd51b1 100644 --- a/src/ast/groovy/org/grails/plugin/cache/compiler/CacheEvictTransformation.groovy +++ b/src/ast/groovy/org/grails/plugin/cache/compiler/CacheEvictTransformation.groovy @@ -29,18 +29,14 @@ import org.codehaus.groovy.ast.stmt.Statement import org.codehaus.groovy.control.CompilePhase import org.codehaus.groovy.control.SourceUnit import org.codehaus.groovy.transform.GroovyASTTransformation -import org.h2.schema.Constant -import org.springframework.cache.Cache import static org.codehaus.groovy.ast.ClassHelper.make import static org.codehaus.groovy.ast.tools.GeneralUtils.block import static org.codehaus.groovy.ast.tools.GeneralUtils.callX -import static org.codehaus.groovy.ast.tools.GeneralUtils.declS import static org.codehaus.groovy.ast.tools.GeneralUtils.ifS import static org.codehaus.groovy.ast.tools.GeneralUtils.notNullX import static org.codehaus.groovy.ast.tools.GeneralUtils.stmt import static org.codehaus.groovy.ast.tools.GeneralUtils.varX -import static org.grails.datastore.gorm.transform.AstMethodDispatchUtils.callD /** * Implementation of {@link CacheEvict} diff --git a/src/ast/groovy/org/grails/plugin/cache/compiler/CacheableTransformation.groovy b/src/ast/groovy/org/grails/plugin/cache/compiler/CacheableTransformation.groovy index ba369659..d275a344 100644 --- a/src/ast/groovy/org/grails/plugin/cache/compiler/CacheableTransformation.groovy +++ b/src/ast/groovy/org/grails/plugin/cache/compiler/CacheableTransformation.groovy @@ -20,12 +20,10 @@ import groovy.transform.CompileStatic import org.codehaus.groovy.ast.AnnotationNode import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.MethodNode -import org.codehaus.groovy.ast.expr.ClosureExpression import org.codehaus.groovy.ast.expr.Expression import org.codehaus.groovy.ast.expr.MethodCallExpression import org.codehaus.groovy.ast.expr.VariableExpression import org.codehaus.groovy.ast.stmt.BlockStatement -import org.codehaus.groovy.ast.stmt.Statement import org.codehaus.groovy.control.CompilePhase import org.codehaus.groovy.control.SourceUnit import org.codehaus.groovy.transform.GroovyASTTransformation diff --git a/src/main/docs/guide/usage/cacheManager.adoc b/src/main/docs/guide/usage/cacheManager.adoc index 1fbb2596..d8dd4878 100644 --- a/src/main/docs/guide/usage/cacheManager.adoc +++ b/src/main/docs/guide/usage/cacheManager.adoc @@ -1,3 +1,3 @@ -The plugin registers an instance of the link:{springApi}/org/springframework/cache/CacheManager.html[CacheManager] iterface as the `grailsCacheManager` Spring bean, so it's easy to access using dependency injection. +The plugin registers an instance of the link:{springApi}/org/springframework/cache/CacheManager.html[CacheManager] interface as the `grailsCacheManager` Spring bean, so it's easy to access using dependency injection. The most common method you would call on the `grailsCacheManager` is `getCache(String name)` to access a link:{springApi}/org/springframework/cache/Cache.html[Cache] instance programmatically. This shouldn't be needed often however. From the `Cache` instance you can also access the underlying cache implementation using `cache.getNativeCache()`. diff --git a/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy b/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy index 454bdfac..5f0e9053 100644 --- a/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy +++ b/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy @@ -9,14 +9,14 @@ class BasicCachingServiceNoCacheManagerSpec extends Specification implements Ser when: 'a cached method is invoked the first time' def result = service.getData() - then: 'the code in the method is exeucted' + then: 'the code in the method is executed' result == 'Hello World!' service.invocationCounter == 1 when: 'a cached method is invoked the second time' result = service.getData() - then: 'the code in the method is still exeucted because no cache manager is present' + then: 'the code in the method is still executed because no cache manager is present' result == 'Hello World!' service.invocationCounter == 2 } diff --git a/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy b/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy index 58367400..261c23a6 100644 --- a/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy +++ b/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy @@ -17,7 +17,7 @@ class BasicCachingServiceSpec extends Specification implements ServiceUnitTest