@RequestMapping("/loginByEmail")
@GlobalInterceptor(checkParams = true)
public ResponseVO loginByEmail(HttpSession httpSession,
HttpServletRequest request,
@VerifyParam(required = true, param = "email") String email,
@VerifyParam(required = true, param = "password") String password,
@VerifyParam(required = true, param = "checkCode") String checkCode) {
try {
// if (!checkCode.equalsIgnoreCase((String) httpSession.getAttribute(CHECK_CODE_KEY))) {
// throw new BusinessException("wrong code");
// }
String token = loginService.loginByEmail(email, password, getIpAddress(request));
httpSession.setAttribute(Constants.SESSION_KEY, token);
return getSuccessResponseVO(token);
} finally {
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
redisTemplate.opsForValue().set("2","2");
redisTemplate.expire("2", 1, TimeUnit.DAYS);
System.out.println(RedisPrefixConstants.SPRING_SESSION_SESSIONS + httpSession.getId());
httpSession.removeAttribute(CHECK_CODE_KEY);
}
}
I tried to test if i can store a data in redis and change it ttl and i succeed but when i change the data that spring session store in redis, i cannot change it. the key is definitely correct because ive already compared. and i dont know why i cannot change it.
redisTemplate
and what library are you using (e.g., lettuce)?