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

为保证长时间登录,不必要使用清空操作,当删除用户后可以调用清空。
posted @ 2019-12-19 15:58  你说累不累  阅读(1372)  评论(0编辑  收藏  举报