Closed YING-HX closed 10 months ago
这个package me.zhengjie.modules.security.security; public void checkRenewal(String token) { // 判断是否续期token,计算token的过期时间 long time = redisUtils.getExpire(properties.getOnlineKey() + token) * 1000; Date expireDate = DateUtil.offset(new Date(), DateField.MILLISECOND, (int) time); // 判断当前时间与过期时间的时间差 long differ = expireDate.getTime() - System.currentTimeMillis(); // 如果在续期检查的范围内,则续期 if (differ <= properties.getDetect()) { long renew = time + properties.getRenew(); redisUtils.expire(properties.getOnlineKey() + token, renew, TimeUnit.MILLISECONDS); } }
redisUtils.getExpire(properties.getOnlineKey() + token) ,这里是不是传错了,导致differ <= properties.getDetect()这里超时了一直在续token
这个package me.zhengjie.modules.security.security; public void checkRenewal(String token) { // 判断是否续期token,计算token的过期时间 long time = redisUtils.getExpire(properties.getOnlineKey() + token) * 1000; Date expireDate = DateUtil.offset(new Date(), DateField.MILLISECOND, (int) time); // 判断当前时间与过期时间的时间差 long differ = expireDate.getTime() - System.currentTimeMillis(); // 如果在续期检查的范围内,则续期 if (differ <= properties.getDetect()) { long renew = time + properties.getRenew(); redisUtils.expire(properties.getOnlineKey() + token, renew, TimeUnit.MILLISECONDS); } }