定时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);
}

为保证长时间登录,不必要使用清空操作,当删除用户后可以调用清空。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章