All Downloads are FREE. Search and download functionalities are using the official Maven repository.

driven-adapter.bin-stash.bin-stash-local-cache-config.mustache Maven / Gradle / Ivy

Go to download

Gradle plugin to create a clean application in Java that already works, It follows our best practices!

There is a newer version: 3.20.10
Show newest version
package {{package}}.binstash.config;

import co.com.bancolombia.binstash.model.api.ObjectCache;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

{{#include-local}}
import co.com.bancolombia.binstash.LocalCacheFactory;
{{/include-local}}
{{#include-centralized}}
import co.com.bancolombia.binstash.CentralizedCacheFactory;
{{/include-centralized}}
{{#include-hybrid}}
import co.com.bancolombia.binstash.HybridCacheFactory;
import co.com.bancolombia.binstash.model.SyncRule;
import java.util.Collections;
import java.util.List;
{{/include-hybrid}}

@Configuration
public class BinStashCacheConfig {

    {{#include-local}}
    @Bean
    public ObjectCache objectCache(LocalCacheFactory localCacheFactory) {
        return localCacheFactory.newObjectCache();
    }
    {{/include-local}}
    {{#include-centralized}}
    @Bean
    public ObjectCache objectCache(CentralizedCacheFactory centralizedCacheFactory) {
        return centralizedCacheFactory.newObjectCache();
    }
    {{/include-centralized}}
    {{#include-hybrid}}
    @Bean
    public List cacheSyncRules() {
        SyncRule simpleSyncRule = (keyArg, syncType) -> true;
        return Collections.singletonList(simpleSyncRule);
    }

    @Bean
    public ObjectCache objectCache(HybridCacheFactory cacheFactory,
        List cacheSyncRules) {
        return cacheFactory.newObjectCache(cacheSyncRules);
    }
    {{/include-hybrid}}
}