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.opendaylight.yangtools.objcache.guava.GuavaObjectCache.java

public GuavaObjectCache(final FinalizableReferenceQueue queue) {
    super(CacheBuilder.newBuilder().softValues().build(), queue);
}

From source file:org.lunifera.runtime.common.state.impl.DirtyDataState.java

protected void ensureCache() {
    if (cache == null) {
        cache = CacheBuilder.newBuilder().initialCapacity(20).weakValues().build();
    }
}

From source file:com.isotrol.impe3.pms.core.support.LoaderCaches.java

private static CacheBuilder<Object, Object> builder(long maximumSize, long hours) {
    return CacheBuilder.newBuilder().maximumSize(maximumSize).softValues().expireAfterAccess(hours * 3600L,
            TimeUnit.SECONDS);/*from  ww  w. ja  v a2  s . c  om*/
}

From source file:edu.illinois.cs.cogcomp.wikifier.utils.datastructure.LRUCache.java

public LRUCache(int maxSize) {
    cache = CacheBuilder.newBuilder().maximumSize(maxSize).build(new CacheLoader<K, V>() {
        @Override//from   w  w w .j  a va2  s.  co m
        public V load(K k) throws Exception {
            return loadValue(k);
        }

    });
}

From source file:org.objectfabric.GoogleCache.java

public GoogleCache() {
    this(CacheBuilder.newBuilder());
}

From source file:com.google.gapid.util.FutureCache.java

public static <K, V> FutureCache<K, V> hardCache(Function<K, ListenableFuture<V>> fetcher,
        Predicate<V> shouldCache) {
    return new FutureCache<K, V>(CacheBuilder.newBuilder().build(), fetcher, shouldCache);
}

From source file:org.geoserver.util.DefaultCacheProvider.java

@Override
public <K extends Serializable, V extends Serializable> Cache<K, V> getCache(String cacheName) {

    Cache<K, V> cache = CacheBuilder.newBuilder().weakValues().concurrencyLevel(DEFAULT_CONCURRENCY_LEVEL)
            .expireAfterAccess(DEFAULT_EXPIRATION_MINUTES, TimeUnit.MINUTES).maximumSize(DEFAULT_MAX_ENTRIES)
            .build();//from w w w . ja va 2  s. com

    return cache;
}

From source file:net.sourcedestination.util.MemoizedFunction.java

/** modifies a function to cache its results
 * /*ww w .  j a v a  2  s  .c om*/
 * @param f function to be memoized
 * @return memoized function f
 */
public static <F, T> MemoizedFunction<F, T> memoize(final Function<F, T> f) {
    return memoize(f, CacheBuilder.newBuilder());
}

From source file:ec.tstoolkit.utilities.GuavaCaches.java

@Nonnull
public static <K, V> Cache<K, V> softValuesCache() {
    return CacheBuilder.newBuilder().softValues().build();
}

From source file:myDarkDiary.service.service.LoginAttemptService.java

public LoginAttemptService() {
    super();/* w  w w  .ja v  a 2  s. com*/
    attemptsCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS)
            .build(new CacheLoader<String, Integer>() {
                @Override
                public Integer load(String key) {
                    return 0;
                }
            });
}