Search in sources :

Example 1 with CouchbaseCache

use of org.springframework.data.couchbase.cache.CouchbaseCache in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method couchbaseCacheExplicitWithTtl.

@Test
void couchbaseCacheExplicitWithTtl() {
    this.contextRunner.withUserConfiguration(CouchbaseConfiguration.class).withPropertyValues("spring.cache.type=couchbase", "spring.cache.cacheNames=foo,bar", "spring.cache.couchbase.expiration=2000").run((context) -> {
        CouchbaseCacheManager cacheManager = getCacheManager(context, CouchbaseCacheManager.class);
        assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
        Cache cache = cacheManager.getCache("foo");
        assertThat(cache).isInstanceOf(CouchbaseCache.class);
        assertThat(((CouchbaseCache) cache).getCacheConfiguration().getExpiry()).hasSeconds(2);
    });
}
Also used : CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Cache(org.springframework.cache.Cache) CaffeineCache(org.springframework.cache.caffeine.CaffeineCache) CouchbaseCache(org.springframework.data.couchbase.cache.CouchbaseCache) Test(org.junit.jupiter.api.Test)

Example 2 with CouchbaseCache

use of org.springframework.data.couchbase.cache.CouchbaseCache in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method couchbaseCacheExplicitWithCaches.

@Test
void couchbaseCacheExplicitWithCaches() {
    this.contextRunner.withUserConfiguration(CouchbaseConfiguration.class).withPropertyValues("spring.cache.type=couchbase", "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar").run((context) -> {
        CouchbaseCacheManager cacheManager = getCacheManager(context, CouchbaseCacheManager.class);
        assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
        Cache cache = cacheManager.getCache("foo");
        assertThat(cache).isInstanceOf(CouchbaseCache.class);
        assertThat(((CouchbaseCache) cache).getCacheConfiguration().getExpiry()).hasSeconds(0);
    });
}
Also used : CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Cache(org.springframework.cache.Cache) CaffeineCache(org.springframework.cache.caffeine.CaffeineCache) CouchbaseCache(org.springframework.data.couchbase.cache.CouchbaseCache) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 Cache (org.springframework.cache.Cache)2 CaffeineCache (org.springframework.cache.caffeine.CaffeineCache)2 ConcurrentMapCache (org.springframework.cache.concurrent.ConcurrentMapCache)2 CouchbaseCache (org.springframework.data.couchbase.cache.CouchbaseCache)2 CouchbaseCacheManager (org.springframework.data.couchbase.cache.CouchbaseCacheManager)2