移除超时的在线用户-完成

pull/2/head
Lyon 2021-03-07 15:49:47 +08:00
parent 2cb7302d30
commit 5803258ed7
2 changed files with 6 additions and 4 deletions

View File

@ -21,9 +21,9 @@ public class SysUserSessionTimeoutJob implements JobHandler {
@Override
public String execute(String param) throws Exception {
log.info("[execute][执行任务:{}]", "清除过期用户信息");
log.info("[execute][执行任务:{}]", "移除超时的在线用户");
long timeoutCount = sysUserSessionService.clearSessionTimeout();
log.info("[execute][执行任务:{}]", "清楚过期用户信息完成" + timeoutCount);
log.info("[execute][执行任务:{}]", "移除超时的在线用户完成" + timeoutCount);
return null;
}

View File

@ -105,9 +105,11 @@ public class SysUserSessionServiceImpl implements SysUserSessionService {
@Override
public long clearSessionTimeout() {
// 获取db里已经超时的用户列表
Long timeoutCount = 0L;
List<SysUserSessionDO> sessionDOS = userSessionMapper.selectSessionTimeout();
for (SysUserSessionDO sessionDO : sessionDOS) {
List<SysUserSessionDO> sessionTimeoutDOS = userSessionMapper.selectSessionTimeout();
for (SysUserSessionDO sessionDO : sessionTimeoutDOS) {
// 确认已经超时,移出在线用户列表
if (loginUserRedisDAO.get(sessionDO.getId()) == null) {
timeoutCount += userSessionMapper.deleteById(sessionDO.getId());
}