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.protocol.pcep.impl.PeerRecord.java

PeerRecord(final long idLifetimeSeconds, final Short lastId) {
    // Note that the cache is limited to 255 entries -- which means we will always have
    // a single entry available. That number will be the Last Recently Used ID.
    this.pastIds = CacheBuilder.newBuilder().expireAfterWrite(idLifetimeSeconds, TimeUnit.SECONDS)
            .maximumSize(Values.UNSIGNED_BYTE_MAX_VALUE).build();
    this.lastId = lastId;
}

From source file:nl.knaw.huygens.timbuctoo.security.LocalLoggedInUsers.java

private static Cache<String, Login> createCache(Configuration config) {
    int duration = config.getIntSetting(Configuration.EXPIRATION_DURATION_KEY);
    TimeUnit timeUnit = TimeUnit.valueOf(config.getSetting(Configuration.EXPIRATION_TIME_UNIT_KEY));
    return CacheBuilder.newBuilder().expireAfterAccess(duration, timeUnit).build();
}

From source file:org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.CachedStoreFactory.java

public CachedStoreFactory(int maxItems) {
    cache = CacheBuilder.newBuilder().maximumSize(maxItems).build();
}

From source file:uk.ac.ed.inf.ace.utils.SoftCache.java

public SoftCache(String name, int evictAfterAccessMinutes, int maximumSize) {
    super("Documents",
            CacheBuilder.newBuilder().concurrencyLevel(1)
                    .expireAfterAccess(evictAfterAccessMinutes, TimeUnit.MINUTES).maximumSize(maximumSize)
                    .build(new CacheLoader<SupplierEx<?>, Object>() {
                        @Override
                        public Object load(SupplierEx<?> key) throws Exception {
                            return key.get();
                        }//from   ww w  .  j  a v a  2  s. c o m
                    }));
}

From source file:com.haulmont.cuba.gui.xml.layout.ScreenXmlDocumentCache.java

protected ScreenXmlDocumentCache(int cacheDescriptorsCount) {
    cache = CacheBuilder.newBuilder().maximumSize(cacheDescriptorsCount).build();
}

From source file:org.onebusaway.gtfs_realtime.archiver.service.TimeServiceImpl.java

@PostConstruct
public void init() {
    sessions = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.DAYS).<String, Session>build().asMap();
}

From source file:org.nmdp.gl.client.ft.JsonGlClientFT.java

@BeforeClass
public static void staticSetUp() {
    jsonFactory = new JsonFactory();
    httpClient = new RestAssuredHttpClient();
    loci = CacheBuilder.newBuilder().initialCapacity(10).build();
    locusIds = CacheBuilder.newBuilder().initialCapacity(10).build();
    alleles = CacheBuilder.newBuilder().initialCapacity(1000).build();
    alleleIds = CacheBuilder.newBuilder().initialCapacity(1000).build();
    jsonClient = new JsonGlClient("http://localhost:10080/gl/", jsonFactory, httpClient, loci, locusIds,
            alleles, alleleIds);/*www. ja v  a  2s  .  co m*/
}

From source file:edu.jhuapl.tinkerpop.cache.ElementCache.java

public ElementCache(int size, int timeout) {
    cache = CacheBuilder.newBuilder().maximumSize(size).expireAfterAccess(timeout, TimeUnit.MILLISECONDS)
            .build();
}

From source file:io.cloudslang.lang.compiler.caching.CachedPrecompileServiceImpl.java

@PostConstruct
public void init() {
    cache = CacheBuilder.newBuilder().maximumSize(500)
            .concurrencyLevel(2 * Runtime.getRuntime().availableProcessors())
            .expireAfterWrite(60, TimeUnit.MINUTES).build();
}

From source file:org.alfresco.repo.lock.mem.LockStoreImpl.java

private static ConcurrentMap<NodeRef, LockState> createMap(long expiry, TimeUnit timeUnit) {
    Cache<NodeRef, LockState> cache = CacheBuilder.newBuilder().concurrencyLevel(32)
            .expireAfterWrite(expiry, timeUnit).build();
    return cache.asMap();
}