We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onlineUserService.checkLoginOnUser(authUser.getUsername(), token);
checkLoginOnUser方法内部用到的
getAll(xxxxxxx)
getAll方法内部用到
List<String> keys = redisUtils.scan(properties.getOnlineKey() + "*"); for (String key : keys) { OnlineUserDto onlineUserDto = (OnlineUserDto) redisUtils.get(key); ..... }
踢掉之前已经登录的token的逻辑有点可怕...性能堪优呐 😓请优化
/** * 检测用户是否在之前已经登录,已经登录踢下线 * @param userName 用户名 */ public void checkLoginOnUser(String userName, String igoreToken){ List<OnlineUserDto> onlineUserDtos = getAll(userName); if(onlineUserDtos ==null || onlineUserDtos.isEmpty()){ return; } for(OnlineUserDto onlineUserDto : onlineUserDtos){ if(onlineUserDto.getUserName().equals(userName)){ try { String token =EncryptUtils.desDecrypt(onlineUserDto.getKey()); if(StringUtils.isNotBlank(igoreToken)&&!igoreToken.equals(token)){ this.kickOut(token); }else if(StringUtils.isBlank(igoreToken)){ this.kickOut(token); } } catch (Exception e) { log.error("checkUser is error",e); } } } }
俺是没有勇气使用号 edisUtils.scan(properties.getOnlineKey() + ""); 呀 😰 更没有勇气循环向redis 索取 redisUtils.get(key) 呀 😰 惊呆啦 , 好yellow好暴力💥
/** * 查询全部数据,不分页 * @param filter / * @return / */ public List<OnlineUserDto> getAll(String filter){ List<String> keys = redisUtils.scan(properties.getOnlineKey() + "*"); Collections.reverse(keys); List<OnlineUserDto> onlineUserDtos = new ArrayList<>(); for (String key : keys) { OnlineUserDto onlineUserDto = (OnlineUserDto) redisUtils.get(key); if(StringUtils.isNotBlank(filter)){ if(onlineUserDto.toString().contains(filter)){ onlineUserDtos.add(onlineUserDto); } } else { onlineUserDtos.add(onlineUserDto); } } onlineUserDtos.sort((o1, o2) -> o2.getLoginTime().compareTo(o1.getLoginTime())); return onlineUserDtos; }
如何优化建议从redis的key名着手
The text was updated successfully, but these errors were encountered:
已更新优化
Sorry, something went wrong.
cf3655a
用户登录优化,踢出用户性能优化,在线用户查询性能优化
0c942c5
elunez/eladmin#802
No branches or pull requests
checkLoginOnUser方法内部用到的
getAll方法内部用到
踢掉之前已经登录的token的逻辑有点可怕...性能堪优呐 😓请优化
俺是没有勇气使用号 edisUtils.scan(properties.getOnlineKey() + ""); 呀 😰
更没有勇气循环向redis 索取 redisUtils.get(key) 呀 😰
惊呆啦 , 好yellow好暴力💥
如何优化建议从redis的key名着手
The text was updated successfully, but these errors were encountered: