mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-06 04:18:07 +00:00
fix 修正 spring cache 获取在线用户失败问题, 回退为使用 redis 工具缓存 ;
update 优化 DictUtils, 使用 CacheUtils 缓存字典数据 ;
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package com.ruoyi.common.dict.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.redis.utils.CacheUtils;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,7 +19,7 @@ public class DictUtils {
|
||||
* @param dictDatas 字典数据列表
|
||||
*/
|
||||
public static void setDictCache(String key, List<SysDictData> dictDatas) {
|
||||
RedisUtils.setCacheObject(getCacheKey(key), dictDatas);
|
||||
CacheUtils.put(CacheNames.SYS_DICT, key, dictDatas);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,11 +29,7 @@ public class DictUtils {
|
||||
* @return dictDatas 字典数据列表
|
||||
*/
|
||||
public static List<SysDictData> getDictCache(String key) {
|
||||
List<SysDictData> dictDatas = RedisUtils.getCacheObject(getCacheKey(key));
|
||||
if (ObjectUtil.isNotNull(dictDatas)) {
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
return CacheUtils.get(CacheNames.SYS_DICT, key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,24 +38,14 @@ public class DictUtils {
|
||||
* @param key 字典键
|
||||
*/
|
||||
public static void removeDictCache(String key) {
|
||||
RedisUtils.deleteObject(getCacheKey(key));
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
public static void clearDictCache() {
|
||||
Collection<String> keys = RedisUtils.keys(CacheConstants.SYS_DICT_KEY + "*");
|
||||
RedisUtils.deleteObject(keys);
|
||||
CacheUtils.clear(CacheNames.SYS_DICT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cache key
|
||||
*
|
||||
* @param configKey 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
public static String getCacheKey(String configKey) {
|
||||
return CacheConstants.SYS_DICT_KEY + configKey;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user