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:be.bittich.quote.config.CacheConfig.java

@Bean
public CacheManager cacheManager() {
    GuavaCacheManager cacheManager = new GuavaCacheManager();
    cacheManager.setCacheBuilder(//from w ww. java 2  s  . c o m
            CacheBuilder.newBuilder().maximumSize(env.getProperty("cache.maxSize", Integer.class))
                    .expireAfterWrite(env.getProperty("cache.expire", Integer.class), TimeUnit.SECONDS));
    return cacheManager;
}

From source file:com.addthis.hydra.query.loadbalance.WorkerTracker.java

public WorkerTracker() {
    this.workerCache = CacheBuilder.newBuilder().maximumSize(DEFAULT_CACHE_SIZE)
            .build(new CacheLoader<String, WorkerData>() {
                @Override/*from   w  w w.  j av a  2s.co m*/
                public WorkerData load(String key) throws Exception {
                    return new WorkerData(key, DEFAULT_WORKER_LEASES);
                }
            });
}

From source file:org.glowroot.transaction.PluginServicesRegistry.java

private PluginServicesRegistry(final PluginServicesFactory pluginServicesFactory) {
    pluginServices = CacheBuilder.newBuilder().build(new CacheLoader<String, PluginServices>() {
        @Override//from  w w  w  .  j  av  a  2  s  . co  m
        public PluginServices load(String pluginId) {
            return pluginServicesFactory.create(pluginId);
        }
    });
    pluginServicesWithoutPlugin = Suppliers.memoize(new Supplier<PluginServices>() {
        @Override
        public PluginServices get() {
            return pluginServicesFactory.create(null);
        }
    });
}

From source file:co.cask.cdap.internal.io.ASMFieldAccessorFactory.java

public ASMFieldAccessorFactory() {
    this.fieldAccessorCache = CacheBuilder.newBuilder().build(new FieldAccessorLoader());
}

From source file:org.seedstack.i18n.internal.I18nCacheProvider.java

@Singleton
@Override//from  www.  ja  v a  2s. c  o  m
public LoadingCache<String, Map<String, String>> get() {
    Configuration configuration = application.getConfiguration();
    int cacheSize = configuration.getInt("org.seedstack.i18n.cache.max-size", DEFAULT_CACHE_SIZE);
    return CacheBuilder.newBuilder().maximumSize(cacheSize)
            .concurrencyLevel(
                    configuration.getInt("org.seedstack.i18n.cache.concurrency", DEFAULT_CACHE_CONCURRENCY))
            .initialCapacity(configuration.getInt("org.seedstack.i18n.cache.initial-size", cacheSize / 4))
            .build(i18nCacheLoader);
}

From source file:com.microsoft.azure.keyvault.extensions.CachingKeyResolver.java

/**
 * Constructor.//w  w  w  . ja  v  a 2  s . c om
 * @param capacity the cache size
 * @param keyResolver the key resolver
 */
public CachingKeyResolver(int capacity, final IKeyResolver keyResolver) {
    cache = CacheBuilder.newBuilder().maximumSize(capacity)
            .build(new CacheLoader<String, ListenableFuture<IKey>>() {

                @Override
                public ListenableFuture<IKey> load(String kid) {
                    return keyResolver.resolveKeyAsync(kid);
                }
            });
}

From source file:rusch.megan6server.cache.AuxiliaryCache.java

public AuxiliaryCache() {
    auxCache = CacheBuilder.newBuilder().maximumSize(10000).build();
}

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

public LoginSubjectCacheProvider() {

    subjectCache = CacheBuilder.newBuilder().maximumSize(100).expireAfterWrite(5, TimeUnit.MINUTES)
            .build(new CacheLoader<String, Subject>() {
                @Override/* w w  w .  j  av a 2  s . c o  m*/
                public Subject load(String id) throws Exception {
                    return subjectService.findUniqueByNamedQuery("Subject.findUserByLogin", id);
                }
            });
}

From source file:io.gromit.geolite2.cache.GuavaCache.java

/**
 * Instantiates a new guava cache./*from   w ww. j  av  a2 s  . c o m*/
 *
 * @param maximumSize the maximum size
 */
public GuavaCache(int maximumSize) {
    cache = CacheBuilder.newBuilder().maximumSize(maximumSize).build();
}

From source file:com.github.fge.grappa.transform.ClassCache.java

private ClassCache() {
    cache = CacheBuilder.newBuilder().recordStats().build(ClassCacheLoader.LOADER);
}