From b3d7221c32430450b3364d55a7e4f5d0f634ba31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=93=E4=BC=9F?= Date: Tue, 29 Aug 2023 08:50:29 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BD=BF=E7=94=A8=20evictIfPresent=20?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=20evict=EF=BC=8C=E7=AB=8B=E5=8D=B3=E5=88=A0?= =?UTF-8?q?=E9=99=A4=201.=20evict=20=E5=BC=82=E6=AD=A5=E6=88=96=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E6=89=A7=E8=A1=8C=202.=20evictIfPresent=20=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E5=88=A0=E9=99=A4=20https://docs.spring.io/spring-fra?= =?UTF-8?q?mework/docs/6.1.x/javadoc-api/org/springframework/cache/Cache.h?= =?UTF-8?q?tml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java | 4 ++-- .../pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java index a9c951da8..8212bbc13 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java @@ -182,8 +182,8 @@ public R 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); // 处理自定义退出事件,保存相关日志 diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java index ba0d1097e..2dbffbc04 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java @@ -192,7 +192,8 @@ public Boolean deleteUserByIds(Long[] ids) { List 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.lambdaQuery().in(SysUserRole::getUserId, CollUtil.toList(ids)));