mirror of https://gitee.com/stylefeng/roses
【8.3.3】【dict】【cache】更新字典缓存的过期时间
parent
4af284608b
commit
5259bd1a12
|
@ -57,4 +57,9 @@ public interface DictConstants {
|
||||||
*/
|
*/
|
||||||
String DELETE_DICT = "DELETE_DICT";
|
String DELETE_DICT = "DELETE_DICT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典默认缓存时间,单位秒
|
||||||
|
*/
|
||||||
|
Long DICT_DEFAULT_CACHE_TIMEOUT_SECONDS = 7200L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants;
|
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.DictException;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.exception.enums.DictExceptionEnum;
|
import cn.stylefeng.roses.kernel.dict.api.exception.enums.DictExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
|
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
|
||||||
|
@ -368,13 +369,13 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
|
||||||
if (sysDict == null) {
|
if (sysDict == null) {
|
||||||
|
|
||||||
// 加入结果到缓存
|
// 加入结果到缓存
|
||||||
dictInfoCache.put(dictId.toString(), new DictDetail());
|
dictInfoCache.put(dictId.toString(), new DictDetail(), DictConstants.DICT_DEFAULT_CACHE_TIMEOUT_SECONDS);
|
||||||
return new DictDetail();
|
return new DictDetail();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// 加入结果到缓存中
|
// 加入结果到缓存中
|
||||||
DictDetail dictDetailTemp = new DictDetail(sysDict.getDictId(), sysDict.getDictCode(), sysDict.getDictName(), sysDict.getDictSort());
|
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;
|
return dictDetailTemp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue