mirror of https://gitee.com/stylefeng/roses
【8.0】【sys】【org】更新sys模块缓存的过期时间
parent
a61d09e384
commit
e33b663dcf
|
@ -67,4 +67,9 @@ public interface SysConstants {
|
|||
*/
|
||||
String ADMIN_USER_ACCOUNT = "admin";
|
||||
|
||||
/**
|
||||
* 默认的sys模块的缓存超时时间
|
||||
*/
|
||||
Long DEFAULT_SYS_CACHE_TIMEOUT_SECONDS = 3600L;
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
|||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveOrgCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.api.enums.org.OrgTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO;
|
||||
|
@ -433,11 +434,11 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
// 查询结果加到缓存中
|
||||
if (hrOrganizationList.size() > 0) {
|
||||
// 过期时间3600秒
|
||||
sysOrgSubFlagCache.put(orgId.toString(), true, 3600L);
|
||||
sysOrgSubFlagCache.put(orgId.toString(), true, SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
|
||||
return true;
|
||||
} else {
|
||||
// 过期时间3600秒
|
||||
sysOrgSubFlagCache.put(orgId.toString(), false, 3600L);
|
||||
sysOrgSubFlagCache.put(orgId.toString(), false, SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
|||
import cn.stylefeng.roses.kernel.sys.api.SysRoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveRoleCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserRoleMapper;
|
||||
|
@ -137,7 +138,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
|
|||
|
||||
// 查询结果缓存起来
|
||||
if (ObjectUtil.isNotEmpty(userRoleQueryResult)) {
|
||||
userRoleCache.put(userId.toString(), userRoleQueryResult);
|
||||
userRoleCache.put(userId.toString(), userRoleQueryResult, SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
|
||||
return userRoleQueryResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ package cn.stylefeng.roses.kernel.sys.starter.cache.org;
|
|||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.cache.impl.TimedCache;
|
||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.cache.subflag.SysOrgSubFlagMemoryCache;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -51,7 +52,7 @@ public class OrgMemoryCacheAutoConfiguration {
|
|||
@Bean
|
||||
public CacheOperatorApi<Boolean> sysOrgSubFlagCache() {
|
||||
// 1小时过期
|
||||
TimedCache<String, Boolean> themeCache = CacheUtil.newTimedCache(1000 * 3600);
|
||||
TimedCache<String, Boolean> themeCache = CacheUtil.newTimedCache(1000 * SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
|
||||
return new SysOrgSubFlagMemoryCache(themeCache);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ package cn.stylefeng.roses.kernel.sys.starter.cache.user;
|
|||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.cache.impl.TimedCache;
|
||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.cache.userrole.UserRoleMemoryCache;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -53,7 +54,7 @@ public class UserMemoryCacheAutoConfiguration {
|
|||
@Bean
|
||||
public CacheOperatorApi<List<Long>> userRoleCache() {
|
||||
// 1小时过期
|
||||
TimedCache<String, List<Long>> cache = CacheUtil.newTimedCache(1000 * 3600);
|
||||
TimedCache<String, List<Long>> cache = CacheUtil.newTimedCache(1000 * SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
|
||||
return new UserRoleMemoryCache(cache);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue