Search in sources :

Example 1 with CouchbaseCacheManager

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

the class CacheAutoConfigurationTests method couchbaseCacheExplicit.

@Test
public void couchbaseCacheExplicit() {
    load(CouchbaseCacheConfiguration.class, "spring.cache.type=couchbase");
    CouchbaseCacheManager cacheManager = validateCacheManager(CouchbaseCacheManager.class);
    assertThat(cacheManager.getCacheNames()).isEmpty();
}
Also used : CouchbaseCacheManager(com.couchbase.client.spring.cache.CouchbaseCacheManager) Test(org.junit.Test)

Example 2 with CouchbaseCacheManager

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

the class CouchbaseCacheConfiguration method cacheManager.

@Bean
public CouchbaseCacheManager cacheManager() {
    List<String> cacheNames = this.cacheProperties.getCacheNames();
    CouchbaseCacheManager cacheManager = new CouchbaseCacheManager(CacheBuilder.newInstance(this.bucket).withExpiration(this.cacheProperties.getCouchbase().getExpirationSeconds()), cacheNames.toArray(new String[cacheNames.size()]));
    return this.customizers.customize(cacheManager);
}
Also used : CouchbaseCacheManager(com.couchbase.client.spring.cache.CouchbaseCacheManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with CouchbaseCacheManager

use of com.couchbase.client.spring.cache.CouchbaseCacheManager 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 4 with CouchbaseCacheManager

use of com.couchbase.client.spring.cache.CouchbaseCacheManager 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

CouchbaseCacheManager (com.couchbase.client.spring.cache.CouchbaseCacheManager)4 Test (org.junit.Test)3 CouchbaseCache (com.couchbase.client.spring.cache.CouchbaseCache)2 Cache (org.springframework.cache.Cache)2 CaffeineCache (org.springframework.cache.caffeine.CaffeineCache)2 ConcurrentMapCache (org.springframework.cache.concurrent.ConcurrentMapCache)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1