Example usage for com.google.common.cache CacheBuilder newBuilder

List of usage examples for com.google.common.cache CacheBuilder newBuilder

Introduction

In this page you can find the example usage for com.google.common.cache CacheBuilder newBuilder.

Prototype

public static CacheBuilder<Object, Object> newBuilder() 

Source Link

Document

Constructs a new CacheBuilder instance with default settings, including strong keys, strong values, and no automatic eviction of any kind.

Usage

From source file:org.nuxeo.client.api.cache.ResultCacheInMemory.java

public ResultCacheInMemory() {
    cache = CacheBuilder.newBuilder().concurrencyLevel(CACHE_CONCURRENCY_LEVEL).maximumSize(CACHE_MAXIMUM_SIZE)
            .expireAfterWrite(CACHE_TIMEOUT, TimeUnit.MINUTES).build();
}

From source file:org.opentripplanner.analyst.request.TileCache.java

public TileCache(GraphService graphService) {
    this.graphService = graphService;
    this.tileCache = CacheBuilder.newBuilder().concurrencyLevel(concurrency).maximumSize(size).build(this);
}

From source file:jbyoshi.robotgame.impl.GameView.java

public GameView(GameModel game, PlayerImpl player) {
    this.model = game;
    this.player = player;
    views = CacheBuilder.newBuilder().weakValues().<Model, ModelView<?>>build(
            CacheLoader.from(model -> ViewRegistry.wrap(model, this)))::getUnchecked;
}

From source file:ro.pippo.pebble.PrettyTimeExtension.java

public PrettyTimeExtension() {
    this.prettyTimeCache = CacheBuilder.newBuilder().maximumSize(10)
            .build(new CacheLoader<Locale, PrettyTime>() {
                @Override/*from   ww w  .  j  a  v  a  2  s .  c  om*/
                public PrettyTime load(Locale locale) throws Exception {
                    return new PrettyTime(locale);
                }
            });
}

From source file:com.glaf.core.cache.guava.GuavaCache.java

public Cache<Object, Object> getCache() {
    if (cache == null) {
        cache = CacheBuilder.newBuilder().maximumSize(getCacheSize())
                .expireAfterAccess(getExpireMinutes(), TimeUnit.MINUTES).build();
    }/*w ww  .j  ava 2 s .  c o  m*/
    return cache;
}

From source file:com.navercorp.pinpoint.profiler.metadata.SimpleCache.java

private ConcurrentMap<T, Result> createCache(int maxCacheSize) {
    final CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder();
    cacheBuilder.concurrencyLevel(64);//from   w  w w .j  a v a  2 s .  c  o  m
    cacheBuilder.initialCapacity(maxCacheSize);
    cacheBuilder.maximumSize(maxCacheSize);
    Cache<T, Result> localCache = cacheBuilder.build();
    ConcurrentMap<T, Result> cache = localCache.asMap();
    return cache;
}

From source file:com.streamsets.lib.security.http.PrincipalCache.java

public PrincipalCache(long principalCacheExpirationMillis, long invalidatedTokensCacheExpirationMillis) {
    principalsCache = CacheBuilder.newBuilder()
            .expireAfterWrite(principalCacheExpirationMillis, TimeUnit.MILLISECONDS).build();
    invalidatedTokens = CacheBuilder.newBuilder()
            .expireAfterWrite(invalidatedTokensCacheExpirationMillis, TimeUnit.MILLISECONDS).build();
}

From source file:com.jeasyxbrl.global.XbrlCache.java

public XbrlCache() {
    //maximuSize is number of data in cache
    xbrlCache = CacheBuilder.newBuilder().maximumSize(100).build();
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.db.AppConfigurationCache.java

private AppConfigurationCache() {
    cache = CacheBuilder.newBuilder().build(new AppConfigurationLoader(new OpenFireDBConnectionProvider()));
}

From source file:com.github.benmanes.caffeine.cache.simulator.policy.product.GuavaPolicy.java

public GuavaPolicy(Config config) {
    policyStats = new PolicyStats("product.Guava");
    BasicSettings settings = new BasicSettings(config);
    cache = CacheBuilder.newBuilder().maximumSize(settings.maximumSize())
            .initialCapacity(settings.maximumSize())
            .removalListener(notification -> policyStats.recordEviction()).build();
}