定时30分钟清除缓存,重置

if(principal!=null){
Integer userId = principal.getId();
System.out.println("userId:" + userId);
String mappingKey = String.format("%s:%s", Configuration.SYSTEM_SESSION_MAPPING_NAMESPACE, userId);
String historySessionId = (String) this.redisTemplate.opsForValue().get(mappingKey);
String sessionKey = String.format("%s:%s", Configuration.SYSTEM_SESSION_NAMESPACE, historySessionId);
this.redisTemplate.expire(sessionKey, 30, TimeUnit.MINUTES);
this.redisTemplate.expire(mappingKey, 30, TimeUnit.MINUTES);
}

为保证长时间登录,不必要使用清空操作,当删除用户后可以调用清空。
原文地址:https://www.cnblogs.com/hxz-nl/p/12068305.html