Skip to content

Commit

Permalink
!415 🐛 使用 evictIfPresent 替换 evict,立即删除
Browse files Browse the repository at this point in the history
Merge pull request !415 from 徐晓伟/dev-evictIfPresent
  • Loading branch information
lltx authored and gitee-org committed Aug 29, 2023
2 parents 64903a4 + b3d7221 commit a333c72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public R<Boolean> removeToken(@PathVariable("token") String token) {
if (accessToken == null || StrUtil.isBlank(accessToken.getToken().getTokenValue())) {
return R.ok();
}
// 清空用户信息
cacheManager.getCache(CacheConstants.USER_DETAILS).evict(authorization.getPrincipalName());
// 清空用户信息(立即删除)
cacheManager.getCache(CacheConstants.USER_DETAILS).evictIfPresent(authorization.getPrincipalName());
// 清空access token
authorizationService.remove(authorization);
// 处理自定义退出事件,保存相关日志
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public Boolean deleteUserByIds(Long[] ids) {
List<SysUser> userList = baseMapper.selectBatchIds(CollUtil.toList(ids));
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
for (SysUser sysUser : userList) {
cache.evict(sysUser.getUsername());
// 立即删除
cache.evictIfPresent(sysUser.getUsername());
}

sysUserRoleMapper.delete(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getUserId, CollUtil.toList(ids)));
Expand Down

0 comments on commit a333c72

Please sign in to comment.