Skip to content

Commit

Permalink
feat: ZSET size 반환 기능 구현 및 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
hongdosan committed Nov 28, 2023
1 parent 20abb0b commit b734916
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public Set<Object> range(String key, long start, long end) {
.opsForZSet()
.range(key, start, end);
}

public Long size(String key) {
return redisTemplate.opsForZSet().size(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,18 @@ void range_less_success() {
// Then
assertThat(actual).hasSize(3);
}

@DisplayName("저장된 데이터 갯수를 조회한다. - Long")
@Test
void size_success() {
// Given
zSetRedisRepository.addIfAbsent(key, value + 1, 1, expire_days);
zSetRedisRepository.addIfAbsent(key, value + 2, 2, expire_days);

// When
Long actual = zSetRedisRepository.size(key);

// Then
assertThat(actual).isEqualTo(2);
}
}

0 comments on commit b734916

Please sign in to comment.