Search in sources :

Example 1 with CouchbaseCache

use of com.couchbase.client.spring.cache.CouchbaseCache in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method couchbaseCacheExplicitWithTtl.

@Test
public void couchbaseCacheExplicitWithTtl() {
    load(CouchbaseCacheConfiguration.class, "spring.cache.type=couchbase", "spring.cache.cacheNames=foo,bar", "spring.cache.couchbase.expiration=2000");
    CouchbaseCacheManager cacheManager = validateCacheManager(CouchbaseCacheManager.class);
    assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
    Cache cache = cacheManager.getCache("foo");
    assertThat(cache).isInstanceOf(CouchbaseCache.class);
    assertThat(((CouchbaseCache) cache).getTtl()).isEqualTo(2);
    assertThat(((CouchbaseCache) cache).getNativeCache()).isEqualTo(this.context.getBean("bucket"));
}
Also used : CouchbaseCacheManager(com.couchbase.client.spring.cache.CouchbaseCacheManager) CouchbaseCache(com.couchbase.client.spring.cache.CouchbaseCache) ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Cache(org.springframework.cache.Cache) CaffeineCache(org.springframework.cache.caffeine.CaffeineCache) CouchbaseCache(com.couchbase.client.spring.cache.CouchbaseCache) Test(org.junit.Test)

Example 2 with CouchbaseCache

use of com.couchbase.client.spring.cache.CouchbaseCache in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method couchbaseCacheExplicitWithCaches.

@Test
public void couchbaseCacheExplicitWithCaches() {
    load(CouchbaseCacheConfiguration.class, "spring.cache.type=couchbase", "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
    CouchbaseCacheManager cacheManager = validateCacheManager(CouchbaseCacheManager.class);
    assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
    Cache cache = cacheManager.getCache("foo");
    assertThat(cache).isInstanceOf(CouchbaseCache.class);
    assertThat(((CouchbaseCache) cache).getTtl()).isEqualTo(0);
    assertThat(((CouchbaseCache) cache).getNativeCache()).isEqualTo(this.context.getBean("bucket"));
}
Also used : CouchbaseCacheManager(com.couchbase.client.spring.cache.CouchbaseCacheManager) CouchbaseCache(com.couchbase.client.spring.cache.CouchbaseCache) ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Cache(org.springframework.cache.Cache) CaffeineCache(org.springframework.cache.caffeine.CaffeineCache) CouchbaseCache(com.couchbase.client.spring.cache.CouchbaseCache) Test(org.junit.Test)

Aggregations

CouchbaseCache (com.couchbase.client.spring.cache.CouchbaseCache)2 CouchbaseCacheManager (com.couchbase.client.spring.cache.CouchbaseCacheManager)2 Test (org.junit.Test)2 Cache (org.springframework.cache.Cache)2 CaffeineCache (org.springframework.cache.caffeine.CaffeineCache)2 ConcurrentMapCache (org.springframework.cache.concurrent.ConcurrentMapCache)2