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

爲保證長時間登錄,不必要使用清空操作,當刪除用戶後可以調用清空。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章