mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
🐛 使用 evictIfPresent 替换 evict,立即删除
1. evict 异步或延迟执行 2. evictIfPresent 立即删除 https://docs.spring.io/spring-framework/docs/6.1.x/javadoc-api/org/springframework/cache/Cache.html
This commit is contained in:
parent
19be64fdf1
commit
f777df58da
@ -182,8 +182,8 @@ public class PigTokenEndpoint {
|
|||||||
if (accessToken == null || StrUtil.isBlank(accessToken.getToken().getTokenValue())) {
|
if (accessToken == null || StrUtil.isBlank(accessToken.getToken().getTokenValue())) {
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
// 清空用户信息
|
// 清空用户信息(立即删除)
|
||||||
cacheManager.getCache(CacheConstants.USER_DETAILS).evict(authorization.getPrincipalName());
|
cacheManager.getCache(CacheConstants.USER_DETAILS).evictIfPresent(authorization.getPrincipalName());
|
||||||
// 清空access token
|
// 清空access token
|
||||||
authorizationService.remove(authorization);
|
authorizationService.remove(authorization);
|
||||||
// 处理自定义退出事件,保存相关日志
|
// 处理自定义退出事件,保存相关日志
|
||||||
|
@ -192,7 +192,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
List<SysUser> userList = baseMapper.selectBatchIds(CollUtil.toList(ids));
|
List<SysUser> userList = baseMapper.selectBatchIds(CollUtil.toList(ids));
|
||||||
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
|
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
|
||||||
for (SysUser sysUser : userList) {
|
for (SysUser sysUser : userList) {
|
||||||
cache.evict(sysUser.getUsername());
|
// 立即删除
|
||||||
|
cache.evictIfPresent(sysUser.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
sysUserRoleMapper.delete(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getUserId, CollUtil.toList(ids)));
|
sysUserRoleMapper.delete(Wrappers.<SysUserRole>lambdaQuery().in(SysUserRole::getUserId, CollUtil.toList(ids)));
|
||||||
|
Loading…
Reference in New Issue
Block a user