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.cloudifysource.cosmo.statecache.NamedLockProvider.java

public NamedLockProvider() {
    lockCache = CacheBuilder.newBuilder().build(new CacheLoader<String, ReentrantLock>() {
        public ReentrantLock load(String name) {
            return new ReentrantLock();
        }/* ww w . j  a v  a2s  .c  o  m*/
    });
}

From source file:com.sk89q.worldguard.bukkit.listener.debounce.EventDebounce.java

public EventDebounce(int debounceTime) {
    cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(debounceTime, TimeUnit.MILLISECONDS)
            .concurrencyLevel(2).build(new CacheLoader<K, Entry>() {
                @Override// w w w .j  a  v  a  2 s .  c  om
                public Entry load(K key) throws Exception {
                    return new Entry();
                }
            });
}

From source file:io.fluo.core.impl.TxInfoCache.java

TxInfoCache(Environment env) {
    cache = CacheBuilder.newBuilder().expireAfterAccess(CACHE_TIMEOUT_MIN, TimeUnit.MINUTES)
            .maximumWeight(10000000).weigher(new TxStatusWeigher()).concurrencyLevel(10).build();
    this.env = env;
}

From source file:org.gradle.api.internal.cache.FileContentCacheBackingStore.java

<V> com.google.common.cache.Cache<HashCode, V> getStore(String name, int normalizedCacheSize) {
    com.google.common.cache.Cache cache = caches.get(name);
    if (cache == null) {
        cache = CacheBuilder.newBuilder().maximumSize(cacheSizer.scaleCacheSize(normalizedCacheSize)).build();
        caches.put(name, cache);/*from www.  j a  v a 2 s . c o  m*/
    }
    return cache;
}

From source file:com.p000ison.dev.simpleclans2.claiming.data.ChunkCache.java

public ChunkCache(int initial, int maxSize, long duration) {
    CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();

    builder.maximumSize(maxSize);/* w  w  w . jav a 2 s  .c  om*/
    builder.expireAfterAccess(duration, TimeUnit.SECONDS);
    builder.initialCapacity(initial);
    //        cache = builder.build(this);
}

From source file:org.artifactory.storage.fs.lock.FsItemsVault.java

public FsItemsVault() {
    locks = CacheBuilder.newBuilder().initialCapacity(2000).softValues()
            .expireAfterAccess(ConstantValues.fsItemCacheIdleTimeSecs.getLong(), TimeUnit.SECONDS)
            .build(new CacheLoader<RepoPath, MonitoringReentrantLock>() {
                @Override//from w  w w.  j  a v  a  2s .c o m
                public MonitoringReentrantLock load(RepoPath key) throws Exception {
                    return new MonitoringReentrantLock();
                }
            });
}

From source file:org.jlgranda.fede.cache.SettingCacheProvider.java

public SettingCacheProvider() {

    cache = CacheBuilder.newBuilder().maximumSize(100).expireAfterWrite(5, TimeUnit.MINUTES)
            .build(new CacheLoader<Long, Setting>() {
                @Override/*from  w w  w.j  a v  a  2 s.co m*/
                public Setting load(Long id) throws Exception {
                    return settingService.find(id);
                }
            });
}

From source file:org.graylog2.indexer.NodeInfoCache.java

@Inject
public NodeInfoCache(Cluster cluster) {
    this.nodeNameCache = CacheBuilder.newBuilder()
            .expireAfterWrite(EXPIRE_DURATION.getQuantity(), EXPIRE_DURATION.getUnit())
            .build(new FunctionCacheLoader<>(cluster::nodeIdToName));
    this.hostNameCache = CacheBuilder.newBuilder()
            .expireAfterWrite(EXPIRE_DURATION.getQuantity(), EXPIRE_DURATION.getUnit())
            .build(new FunctionCacheLoader<>(cluster::nodeIdToHostName));
}

From source file:org.polarsys.reqcycle.traceability.storage.sesame.storage.repositoryholders.AbstractSesameRepositoryHolder.java

public AbstractSesameRepositoryHolder() {
    super();/*from   www  . ja v  a 2  s.  c  om*/

    repositories = CacheBuilder.newBuilder().build(new InitRepositoryCallable());
    connections = CacheBuilder.newBuilder().build(new ThreadLocalConnectionsBuilderCallable());
}

From source file:org.apache.hadoop.hive.ql.plan.mapper.CachingStatsSource.java

public CachingStatsSource(int cacheSize) {
    cache = CacheBuilder.newBuilder().maximumSize(cacheSize).build();
}