Skip to content

Commit

Permalink
Feat: redisKey로 키워드 리스트 조회 (#145)
Browse files Browse the repository at this point in the history
* Feat: redisKey로 키워드 리스트 조회
  • Loading branch information
emes-g authored Aug 19, 2024
1 parent 062e6f2 commit aa54844
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/store/itpick/backend/util/Redis.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,17 @@ private static int getWeight(String key) {
}
return -1;
}

public List<String> getKeywordListByRedisKey(String redisKey) {
ZSetOperations<String, Object> zSetOperations = redisTemplate.opsForZSet();

if (zSetOperations.size(redisKey) < 10) {
return null;
}
List<String> keywordList = new ArrayList<>();
for (Object keyword : zSetOperations.reverseRange(redisKey, 0, 9)) {
keywordList.add((String) keyword);
}
return keywordList;
}
}

0 comments on commit aa54844

Please sign in to comment.