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.cryptomator.cryptofs.DirectoryIdProvider.java

@Inject
public DirectoryIdProvider(DirectoryIdLoader directoryIdLoader) {
    ids = CacheBuilder.newBuilder().maximumSize(MAX_CACHE_SIZE).build(directoryIdLoader);
}

From source file:com.fitbur.core.guava.cache.CacheBuilderProvider.java

@Override
public CacheBuilder provide() {
    return CacheBuilder.newBuilder();
}

From source file:org.rub.nds.saml.samllib.verifier.SAMLIDCache.java

/**
 *
 *///from   www.  ja  va 2s  .co m
public static void initialize() {
    SAMLIDCache.cachedIDs = CacheBuilder.newBuilder().maximumSize(1000)
            .expireAfterWrite(SAMLIDCache.cacheDuration, TimeUnit.MINUTES)
            .removalListener(new RemovalListener<String, String>() {
                @Override
                public void onRemoval(RemovalNotification<String, String> rn) {
                    _log.debug("SAML Response ID " + rn.getKey() + " has been removed from the cache.");
                }
            }).build(new CacheLoader<String, String>() {
                @Override
                public String load(String key) {
                    return key;
                }
            });
}

From source file:org.yqm.nlp.cn.seg.impl.CacheSegTagger.java

public CacheSegTagger(ISegTagger segger) {
    this.segger = segger;
    cache = CacheBuilder.newBuilder().maximumSize(5000).expireAfterAccess(10, TimeUnit.MINUTES)
            .build(new CacheLoader<String, String>() {

                @Override/*  w w  w . j  av a  2s  .c  om*/
                public String load(String text) throws Exception {
                    return seg4cache(text);
                }
            });
}

From source file:com.googlesource.gerrit.plugins.lfs.LfsRepositoriesCache.java

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

From source file:it.units.malelab.ege.util.distance.CachedDistance.java

private void buildCache() {
    cache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).build(new CacheLoader<List<T>, Double>() {
        @Override/*  w  w w .  j a va 2s .c  om*/
        public Double load(List<T> ts) throws Exception {
            double d = distance.d(ts.get(0), ts.get(1));
            cache.put(Arrays.asList(ts.get(1), ts.get(0)), d); //put pair in the other order
            return d;
        }
    });
}

From source file:org.fineract.module.stellar.listener.ValueSynchronizer.java

public ValueSynchronizer() {
    valueLocks = CacheBuilder.newBuilder().build(new CacheLoader<T, Lock>() {
        public Lock load(final T id) {
            return new ReentrantLock();
        }/*from w w w  .j  av  a2  s .co m*/
    });
}

From source file:net.maritimecloud.mms.server.rest.TailLogger.java

public TailLogger() {
    CacheBuilder<Object, Object> b = CacheBuilder.newBuilder();
    b.expireAfterAccess(1, TimeUnit.HOURS);
    cache = b.build();
}

From source file:business.GuavaUtils.java

public static <K, V> LoadingCache<K, V> makeCache(com.google.common.base.Function<K, V> cacheLoadFunction) {
    return CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).concurrencyLevel(8).recordStats()
            .maximumSize(1000).initialCapacity(100).build(CacheLoader.from(cacheLoadFunction));
}

From source file:com.boundlessgeo.geoserver.Proj.java

Proj() {
    cache = CacheBuilder.newBuilder().maximumSize(10).build();
    try {//from   ww  w  .ja v  a 2 s . c o m
        cache.put("EPSG:4326", CRS.decode("EPSG:4326"));
        cache.put("EPSG:3857", CRS.decode("EPSG:3857"));
    } catch (Exception e) {
        // something is pretty wrong if this happens
        throw new RuntimeException(e);
    }
}