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.google.gapid.util.FutureCache.java

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

From source file:com.google.gitiles.TimeCache.java

public static CacheBuilder<Object, Object> defaultBuilder() {
    return CacheBuilder.newBuilder().maximumSize(10 << 10);
}

From source file:com.solidbeans.core.security.jwt.spring.JtiCache.java

private JtiCache(ClaimsConfig config) {
    this.cache = CacheBuilder.newBuilder().maximumSize(config.getCacheMaxSize())
            .expireAfterAccess(config.getCacheTime(), config.getCacheTimeUnit()).build();
}

From source file:com.google.gitiles.BlameCache.java

public static CacheBuilder<Object, Object> newBuilder() {
    return CacheBuilder.newBuilder().maximumWeight(10 << 10);
}

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

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

From source file:git.reflect.SessionCache.java

private SessionCache() {
    cache = CacheBuilder.newBuilder().expireAfterAccess(EXPIRE_TIME, TimeUnit.MINUTES).build();
}

From source file:com.android.tools.idea.gradle.project.GradleProjectDependencyParser.java

@NotNull
public static Function<VirtualFile, Iterable<String>> newInstance(@NotNull final Project project) {
    return CacheBuilder.newBuilder().build(new CacheLoader<VirtualFile, Iterable<String>>() {
        @Override/*from w  ww .  j a va  2 s . co m*/
        public Iterable<String> load(@NotNull VirtualFile key) throws Exception {
            return parse(key, project);
        }
    });
}

From source file:org.rapidoid.plugins.cache.guava.GuavaCache.java

@SuppressWarnings("unchecked")
private static <K, V> CacheBuilder<K, V> builder(long timeToLiveMs, boolean resetTimeToLiveWhenAccessed) {
    CacheBuilder<K, V> builder = (CacheBuilder<K, V>) CacheBuilder.newBuilder();

    if (resetTimeToLiveWhenAccessed) {
        return builder.expireAfterAccess(timeToLiveMs, TimeUnit.MILLISECONDS);
    } else {//ww w  .j  a  v a 2  s . c  o  m
        return builder.expireAfterWrite(timeToLiveMs, TimeUnit.MILLISECONDS);
    }
}

From source file:pl.psi.licensing.license.monitoring.LicenseSessionRegistry.java

public LicenseSessionRegistry() {
    licenseSessionRegistry = CacheBuilder.newBuilder().expireAfterAccess(24, TimeUnit.HOURS).build();

}

From source file:org.onos.yangtools.objcache.guava.GuavaObjectCache.java

public GuavaObjectCache(final FinalizableReferenceQueue queue) {
    super(CacheBuilder.newBuilder().softValues().<SoftKey<?>, Object>build(), queue);
}