Search in sources :

Example 1 with RedisCache

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);
}
Also used : RedisCache(org.springframework.data.redis.cache.RedisCache) MeterBinder(io.micrometer.core.instrument.binder.MeterBinder) Test(org.junit.jupiter.api.Test)

Example 2 with RedisCache

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;
}
Also used : RedisCache(org.springframework.data.redis.cache.RedisCache) RedisCacheManager(org.springframework.data.redis.cache.RedisCacheManager)

Example 3 with RedisCache

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();
    });
}
Also used : RedisCache(org.springframework.data.redis.cache.RedisCache) Test(org.junit.jupiter.api.Test)

Aggregations

RedisCache (org.springframework.data.redis.cache.RedisCache)3 Test (org.junit.jupiter.api.Test)2 MeterBinder (io.micrometer.core.instrument.binder.MeterBinder)1 RedisCacheManager (org.springframework.data.redis.cache.RedisCacheManager)1