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:com.facebook.buck.query.CachingQueryEvaluator.java

public CachingQueryEvaluator() {
    this.cache = CacheBuilder.newBuilder().build();
}

From source file:org.seedstack.i18n.internal.infrastructure.jpa.I18nCacheProvider.java

@Singleton
@Override//from w  ww  .j  a va2 s  .  co m
public LoadingCache<String, Map<String, String>> get() {
    return CacheBuilder.newBuilder().maximumSize(cacheConfig.getMaxSize())
            .concurrencyLevel(cacheConfig.getConcurrencyLevel()).initialCapacity(cacheConfig.getInitialSize())
            .build(i18nCacheLoader);
}

From source file:com.rhythm.louie.cache.GuavaLoadingCache.java

@SuppressWarnings("unchecked")
public static <K, V> GuavaLoadingCache<K, V> permanent(String name, CacheLoader<K, V> loader) {
    return new GuavaLoadingCache(name, CacheBuilder.newBuilder(), loader);
}

From source file:de.fhws.applab.restserverspi.localcache.AbstractLocalCache.java

public AbstractLocalCache(long maxCacheSize) {
    this.cache = CacheBuilder.newBuilder().maximumSize(maxCacheSize).build();
}

From source file:com.codefollower.lealone.omid.tso.GuavaCache.java

public GuavaCache(int size) {
    cache = CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(size).initialCapacity(size)
            .removalListener(this).build();
}

From source file:com.google.gitiles.blame.BlameCacheImpl.java

public static CacheBuilder<Key, List<Region>> defaultBuilder() {
    return weigher(CacheBuilder.newBuilder()).maximumWeight(10 << 10);
}

From source file:com.baidu.oped.apm.profiler.metadata.LRUCache.java

public LRUCache(int maxCacheSize) {
    final CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder();
    cacheBuilder.concurrencyLevel(32);/*from www.  j  av a2  s  . c  o  m*/
    cacheBuilder.initialCapacity(maxCacheSize);
    cacheBuilder.maximumSize(maxCacheSize);
    Cache<T, Object> localCache = cacheBuilder.build();
    this.cache = localCache.asMap();
}

From source file:dk.dma.ais.track.store.CacheTargetStore.java

@Inject
public CacheTargetStore(AisTrackConfiguration cfg) {
    cache = CacheBuilder.newBuilder().expireAfterWrite(cfg.targetExpire().toMillis(), TimeUnit.MILLISECONDS)
            .maximumSize(5000000).build();
}

From source file:com.bennavetta.appsite.processor.scripting.ScriptFactory.java

public ScriptFactory(ScriptCompiler compiler, long maxSize, long scriptLife, TimeUnit unit) {
    this.compiler = compiler;
    this.cache = CacheBuilder.newBuilder().maximumSize(maxSize).expireAfterWrite(scriptLife, unit)
            .build(new CacheLoader<String, Script>() {
                @Override//from w  w w . ja  v a2 s .  c o m
                public Script load(String key) throws Exception {
                    return ScriptFactory.this.compiler.compile(key);
                }
            });
}

From source file:rapture.kernel.cache.KernelCaches.java

private static Cache<RaptureURI, Optional<String>> setupObjectStorageCache() {
    return CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES)
            .removalListener(new RemovalListener<RaptureURI, Optional<String>>() {
                @Override//from ww w.j a  v  a 2 s .  c o m
                public void onRemoval(RemovalNotification<RaptureURI, Optional<String>> notification) {
                    if (notification.getCause() != RemovalCause.REPLACED) {
                        if (log.isTraceEnabled())
                            log.trace("Removed " + notification.getKey() + " from local cache because "
                                    + notification.getCause());
                    }
                }
            }).build();
}