1. getPopularKeywordsWithScores(int topN)

public Set<ZSetOperations.TypedTuple<String>> getPopularKeywordsWithScores(int topN) {
    return stringRedisTemplate.opsForZSet().reverseRangeWithScores(POPULAR_KEYWORD, 0, topN - 1);
}

2. getPopularKeywordResponses(int topN)

public List<PopularKeywordResponse> getPopularKeywordResponses(int topN) {
    Set<ZSetOperations.TypedTuple<String>> tuples = getPopularKeywordsWithScores(topN);
    List<PopularKeywordResponse> result = new ArrayList<>();
    int rank = 1;
    for (ZSetOperations.TypedTuple<String> tuple : tuples) {
        result.add(new PopularKeywordResponse(rank++, tuple.getValue()));
    }
    return result;
}

정리하면

메서드 역할 반환값 비고
getPopularKeywordsWithScores Redis에서 인기 검색어 + 점수를 원본 그대로 조회 Set<TypedTuple<String>> 점수까지 함께 가져옴
getPopularKeywordResponses 원본 데이터를 순위 붙인 DTO 리스트로 변환 List<PopularKeywordResponse> 클라이언트 응답에 맞춰 가공

추가 팁