I'm trying to manage refresh token w redis. I checked that the data exists on redis when I saved new Redis redisRepository.save(new Redis(userEmail, token.getRefreshToken()));.
But when I used redisRepository.findByEmail, it returned null even if the exact data exists on redis. I don't understand why it doesn't returns the data.
Redis
import org.springframework.data.annotation.Id;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.redis.core.RedisHash;
@RedisHash(value = "refreshToken", timeToLive = 60 * 60 * 24 * 14)
@AllArgsConstructor
@Getter
@Setter
public class Redis {
@Id
private String email;
private String refreshToken;
}
RedisRepository
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
public interface RedisRepository extends CrudRepository<Redis, String> {
Optional<Redis> findByEmail(String email);
}