| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | |
| | | */ |
| | | public static void setDictCache(String key, List<SysDictData> dictDatas) |
| | | { |
| | | SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(key), dictDatas); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static List<SysDictData> getDictCache(String key) |
| | | { |
| | | Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); |
| | | Object cacheObj = RedisUtils.getCacheObject(getCacheKey(key)); |
| | | if (StringUtils.isNotNull(cacheObj)) |
| | | { |
| | | List<SysDictData> dictDatas = (List<SysDictData>)cacheObj; |
| | |
| | | */ |
| | | public static void removeDictCache(String key) |
| | | { |
| | | SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key)); |
| | | RedisUtils.deleteObject(getCacheKey(key)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static void clearDictCache() |
| | | { |
| | | Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*"); |
| | | SpringUtils.getBean(RedisCache.class).deleteObject(keys); |
| | | Collection<String> keys = RedisUtils.keys(Constants.SYS_DICT_KEY + "*"); |
| | | RedisUtils.deleteObject(keys); |
| | | } |
| | | |
| | | /** |