Skip to content

Commit afce58c

Browse files
committed
Apply Closable, DisposableBean into RedisValidator
1 parent acea8dd commit afce58c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/com/longcoding/moon/helpers/RedisValidator.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import redis.clients.jedis.Jedis;
88
import redis.clients.jedis.Transaction;
99

10+
import java.io.Closeable;
11+
import java.io.IOException;
1012
import java.util.LinkedHashMap;
1113

1214
/**
@@ -20,7 +22,7 @@
2022
*/
2123
@Getter
2224
@EqualsAndHashCode
23-
public class RedisValidator<T> {
25+
public class RedisValidator<T> implements DisposableBean, Closeable {
2426

2527
private Jedis jedis;
2628
private Transaction jedisMulti;
@@ -47,4 +49,13 @@ public RedisValidator(Jedis jedis) {
4749
*/
4850
public void offerFutureMethodQueue(String className, T responseValue) { futureMethodQueue.put(className, responseValue); }
4951

52+
@Override
53+
public void close() throws IOException {
54+
jedis.close();
55+
}
56+
57+
@Override
58+
public void destroy() throws Exception {
59+
jedis.close();
60+
}
5061
}

0 commit comments

Comments
 (0)