From f5d7cb0f84ccdfe02fcf377f2b5c22995f4fcfc2 Mon Sep 17 00:00:00 2001 From: "Tucker J. Pelletier" Date: Fri, 2 Dec 2022 11:17:29 -0500 Subject: [PATCH 1/2] Fixing tests --- build.gradle | 1 + .../grails/plugins/redis/RedisServiceSpec.groovy | 10 ++-------- .../groovy/grails/plugins/redis/RedisTagLibSpec.groovy | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index e105a03..4bb1457 100644 --- a/build.gradle +++ b/build.gradle @@ -59,6 +59,7 @@ dependencies { console "org.grails:grails-console" compile 'redis.clients:jedis:4.3.1' + compile 'org.apache.commons:commons-pool2:2.11.1' compile 'com.google.code.gson:gson:2.9.1' } diff --git a/src/test/groovy/grails/plugins/redis/RedisServiceSpec.groovy b/src/test/groovy/grails/plugins/redis/RedisServiceSpec.groovy index cd3a29f..9b4d7fe 100644 --- a/src/test/groovy/grails/plugins/redis/RedisServiceSpec.groovy +++ b/src/test/groovy/grails/plugins/redis/RedisServiceSpec.groovy @@ -2,20 +2,14 @@ package grails.plugins.redis import grails.core.GrailsApplication import grails.spring.BeanBuilder -import grails.test.mixin.integration.Integration -import groovy.util.logging.Slf4j +import grails.testing.mixin.integration.Integration import org.springframework.beans.factory.annotation.Autowired import redis.clients.jedis.Jedis import redis.clients.jedis.Transaction import redis.clients.jedis.exceptions.JedisConnectionException import spock.lang.Specification -import java.util.concurrent.Callable -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.ConcurrentMap -import java.util.concurrent.CountDownLatch -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors +import java.util.concurrent.* import static grails.plugins.redis.RedisService.NO_EXPIRATION_TTL diff --git a/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy b/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy index c6393a9..597a335 100644 --- a/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy +++ b/src/test/groovy/grails/plugins/redis/RedisTagLibSpec.groovy @@ -1,7 +1,7 @@ package grails.plugins.redis import grails.core.GrailsApplication -import grails.test.mixin.integration.Integration +import grails.testing.mixin.integration.Integration import org.springframework.beans.factory.annotation.Autowired import spock.lang.Ignore import spock.lang.Specification From 66e148414918076209fc7b41a29448e7dd19f337 Mon Sep 17 00:00:00 2001 From: "Tucker J. Pelletier" Date: Fri, 9 Dec 2022 13:25:03 -0500 Subject: [PATCH 2/2] Adding a delete key method. --- .../groovy/grails/plugins/redis/RedisService.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/groovy/grails/plugins/redis/RedisService.groovy b/src/main/groovy/grails/plugins/redis/RedisService.groovy index 4cb691d..b8a7580 100644 --- a/src/main/groovy/grails/plugins/redis/RedisService.groovy +++ b/src/main/groovy/grails/plugins/redis/RedisService.groovy @@ -363,6 +363,17 @@ class RedisService { } } + /** + * Deletes key from redis. + * + * @param key The key to delete. + */ + void deleteKey(String key){ + withRedis { Jedis redis -> + redis.del(key) + } + } + def memoizeList(String key, Integer expire, Closure closure) { memoizeList(key, [expire: expire], closure) }