Search in sources :

Example 1 with Couchbase

use of org.springframework.boot.autoconfigure.cache.CacheProperties.Couchbase in project spring-boot by spring-projects.

the class CouchbaseCacheConfiguration method cacheManager.

@Bean
CouchbaseCacheManager cacheManager(CacheProperties cacheProperties, CacheManagerCustomizers customizers, ObjectProvider<CouchbaseCacheManagerBuilderCustomizer> couchbaseCacheManagerBuilderCustomizers, CouchbaseClientFactory clientFactory) {
    List<String> cacheNames = cacheProperties.getCacheNames();
    CouchbaseCacheManagerBuilder builder = CouchbaseCacheManager.builder(clientFactory);
    Couchbase couchbase = cacheProperties.getCouchbase();
    org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration config = org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration.defaultCacheConfig();
    if (couchbase.getExpiration() != null) {
        config = config.entryExpiry(couchbase.getExpiration());
    }
    builder.cacheDefaults(config);
    if (!ObjectUtils.isEmpty(cacheNames)) {
        builder.initialCacheNames(new LinkedHashSet<>(cacheNames));
    }
    couchbaseCacheManagerBuilderCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder));
    CouchbaseCacheManager cacheManager = builder.build();
    return customizers.customize(cacheManager);
}
Also used : Couchbase(org.springframework.boot.autoconfigure.cache.CacheProperties.Couchbase) CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) CouchbaseCacheManagerBuilder(org.springframework.data.couchbase.cache.CouchbaseCacheManager.CouchbaseCacheManagerBuilder) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Couchbase (org.springframework.boot.autoconfigure.cache.CacheProperties.Couchbase)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 CouchbaseCacheManager (org.springframework.data.couchbase.cache.CouchbaseCacheManager)1 CouchbaseCacheManagerBuilder (org.springframework.data.couchbase.cache.CouchbaseCacheManager.CouchbaseCacheManagerBuilder)1