opt:6.15上线装箱区代码修改
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.nl.modules.common.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.slf4j.Logger;
|
||||
@@ -42,6 +44,11 @@ public class RedisUtils {
|
||||
@Value("${jwt.online-key}")
|
||||
private String onlineKey;
|
||||
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
||||
|
||||
public RedisUtils(RedisTemplate<Object, Object> redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
@@ -708,4 +715,25 @@ public class RedisUtils {
|
||||
log.debug("缓存删除数量:" + count + "个");
|
||||
log.debug("--------------------------------------------");
|
||||
}
|
||||
|
||||
public void pushToList(String key, Object value) {
|
||||
try {
|
||||
String valueJson = objectMapper.writeValueAsString(value);
|
||||
redisTemplate.opsForList().rightPush(key, valueJson);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("序列化对象出错:", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object popFromList(String key, Class<?> valueType) {
|
||||
String valueJson = (String) redisTemplate.opsForList().leftPop(key);
|
||||
if (valueJson != null) {
|
||||
try {
|
||||
return objectMapper.readValue(valueJson, valueType);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("反序列化对象出错:", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user