Просмотр исходного кода

fix cache

release_toaliyun_real
xiaohanzi 5 лет назад
Родитель
Сommit
a739abed4e
1 измененных файлов: 5 добавлений и 14 удалений
  1. +5
    -14
      mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java

+ 5
- 14
mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java Просмотреть файл

@@ -11,11 +11,13 @@ import org.springframework.data.redis.core.ValueOperations;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.base.BaseCUserEntity;

public class RedisCacheUtils {

private static <T> T parseJson(String json,Class<T> clazz) {
return JSON.parseObject(json,new TypeReference<T>() {});
return JSON.parseObject(json,clazz);
}
private static <T> List<T> parseListJson(String json,Class<T> clazz) {
@@ -63,12 +65,7 @@ public class RedisCacheUtils {
}
public static Map getCacheMap(RedisTemplate<String, Object> template,String key) {
if (template.hasKey(key)) {
ValueOperations<String, Object> operations = template.opsForValue();
Object o = operations.get(key);
return parseJson(JSON.toJSONString(o), Map.class);
}
return null;
return getCacheObject(template,key,Map.class);
}
public static String getCacheString(RedisTemplate<String, Object> template,String key) {
@@ -129,13 +126,7 @@ public class RedisCacheUtils {
}
public static Map getMapFieldObject(Object o,String property) {
String json = JSON.toJSONString(o);
JSONObject jsonObject = JSON.parseObject(json);
Object p = jsonObject.get(property);
if (null != p ) {
return parseJson(JSON.toJSONString(p), Map.class);
}
return null;
return getFieldObject(o,property,Map.class);
}
public static void removeCache(RedisTemplate<String, Object> template,String key) {


Загрузка…
Отмена
Сохранить