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

為保證長時間登錄,不必要使用清空操作,當刪除用戶后可以調用清空。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM