use of org.springframework.data.redis.cache.RedisCache in project spring-boot by spring-projects.
the class RedisCacheMeterBinderProviderTests method redisCacheProvider.
@Test
void redisCacheProvider() {
RedisCache cache = mock(RedisCache.class);
given(cache.getName()).willReturn("test");
MeterBinder meterBinder = new RedisCacheMeterBinderProvider().getMeterBinder(cache, Collections.emptyList());
assertThat(meterBinder).isInstanceOf(RedisCacheMetrics.class);
}
use of org.springframework.data.redis.cache.RedisCache in project spring-boot by spring-projects.
the class RedisCacheMetricsTests method getTestCache.
private RedisCache getTestCache(AssertableApplicationContext context) {
assertThat(context).hasSingleBean(RedisCacheManager.class);
RedisCacheManager cacheManager = context.getBean(RedisCacheManager.class);
RedisCache cache = (RedisCache) cacheManager.getCache("test");
assertThat(cache).isNotNull();
return cache;
}
use of org.springframework.data.redis.cache.RedisCache in project spring-boot by spring-projects.
the class RedisCacheMetricsTests method cacheMetricsMatchCacheStatistics.
@Test
void cacheMetricsMatchCacheStatistics() {
this.contextRunner.run((context) -> {
RedisCache cache = getTestCache(context);
RedisCacheMetrics cacheMetrics = new RedisCacheMetrics(cache, TAGS);
assertThat(cacheMetrics.hitCount()).isEqualTo(cache.getStatistics().getHits());
assertThat(cacheMetrics.missCount()).isEqualTo(cache.getStatistics().getMisses());
assertThat(cacheMetrics.putCount()).isEqualTo(cache.getStatistics().getPuts());
assertThat(cacheMetrics.size()).isNull();
assertThat(cacheMetrics.evictionCount()).isNull();
});
}
Aggregations