|
@@ -7,11 +7,14 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class RedisUtil {
|
|
|
|
|
|
@Resource(name = "alarmRedisTemplate")
|
|
@@ -117,17 +120,16 @@ public class RedisUtil {
|
|
|
* @return true成功 false失败
|
|
|
*/
|
|
|
|
|
|
- public boolean set(String key, Object value) {
|
|
|
+ public boolean set(String key, String value) {
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
redisTemplate.opsForValue().set(key, value);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("redis保存数据失败", e);
|
|
|
|
|
|
return false;
|
|
|
|
|
@@ -144,7 +146,7 @@ public class RedisUtil {
|
|
|
* @return true成功 false 失败
|
|
|
*/
|
|
|
|
|
|
- public boolean set(String key, Object value, long time) {
|
|
|
+ public boolean set(String key, String value, long time) {
|
|
|
|
|
|
try {
|
|
|
|
|
@@ -162,7 +164,7 @@ public class RedisUtil {
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("redis保存数据失败", e);
|
|
|
|
|
|
return false;
|
|
|
|