Skip to content

Commit

Permalink
fix: Redis 최근검색어 조회 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
chris910512 committed Jan 11, 2024
1 parent 4a03fca commit 0f0f0f6
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -41,9 +42,15 @@ public void saveRecentSearchLog(String oauthId, String keyword) {
@Override
public List<String> getRecentSearchLogs(String oauthId) {
String key = searchLogKey(oauthId);
List<SearchLog> range = redisTemplate.opsForList()
.range(key, 0, RECENT_KEYWORD_SIZE);
List<SearchLog> range = new ArrayList<>();

try {
range = redisTemplate.opsForList()
.range(key, 0, RECENT_KEYWORD_SIZE);
} catch (Exception e) {
log.error("getRecentSearchLogs error: " + key);
}

return Objects.requireNonNull(range).stream().map(SearchLog::getKeyword).toList();
}

Expand Down

0 comments on commit 0f0f0f6

Please sign in to comment.