|
@@ -1,14 +1,14 @@
|
|
|
package com.qmth.exam.reserve.cache;
|
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
@Component
|
|
|
public class RedisClient {
|
|
|
|
|
@@ -17,8 +17,8 @@ public class RedisClient {
|
|
|
@Resource
|
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
- // @Resource
|
|
|
- // private RedissonClient redissonClient;
|
|
|
+ @Resource
|
|
|
+ private RedissonClient redissonClient;
|
|
|
|
|
|
public void set(String key, Object value) {
|
|
|
redisTemplate.opsForValue().set(key, value);
|
|
@@ -50,8 +50,12 @@ public class RedisClient {
|
|
|
return redisTemplate.hasKey(key);
|
|
|
}
|
|
|
|
|
|
- public boolean tryLock(String key, Object value, long timeout, TimeUnit timeUnit) {
|
|
|
- return redisTemplate.opsForValue().setIfAbsent(key, value, timeout, timeUnit).booleanValue();
|
|
|
+ public RedisTemplate<String, Object> getRedisTemplate() {
|
|
|
+ return redisTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public RedissonClient getRedissonClient() {
|
|
|
+ return redissonClient;
|
|
|
}
|
|
|
|
|
|
}
|