【8.3.3】【dict】【cache】更新字典缓存的过期时间

pull/62/head
stylefeng 2025-01-14 16:22:47 +08:00
parent 4af284608b
commit 5259bd1a12
2 changed files with 8 additions and 2 deletions

View File

@ -57,4 +57,9 @@ public interface DictConstants {
*/
String DELETE_DICT = "DELETE_DICT";
/**
*
*/
Long DICT_DEFAULT_CACHE_TIMEOUT_SECONDS = 7200L;
}

View File

@ -30,6 +30,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants;
import cn.stylefeng.roses.kernel.dict.api.constants.DictConstants;
import cn.stylefeng.roses.kernel.dict.api.exception.DictException;
import cn.stylefeng.roses.kernel.dict.api.exception.enums.DictExceptionEnum;
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
@ -368,13 +369,13 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
if (sysDict == null) {
// 加入结果到缓存
dictInfoCache.put(dictId.toString(), new DictDetail());
dictInfoCache.put(dictId.toString(), new DictDetail(), DictConstants.DICT_DEFAULT_CACHE_TIMEOUT_SECONDS);
return new DictDetail();
} else {
// 加入结果到缓存中
DictDetail dictDetailTemp = new DictDetail(sysDict.getDictId(), sysDict.getDictCode(), sysDict.getDictName(), sysDict.getDictSort());
dictInfoCache.put(dictId.toString(), dictDetailTemp);
dictInfoCache.put(dictId.toString(), dictDetailTemp, DictConstants.DICT_DEFAULT_CACHE_TIMEOUT_SECONDS);
return dictDetailTemp;
}