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.hortonworks.registries.schemaregistry.SchemaVersionInfoCache.java

public SchemaVersionInfoCache(final SchemaRetriever schemaRetriever, final long schemaCacheSize,
        final long schemaCacheExpiryInMilliSecs) {
    loadingCache = CacheBuilder.newBuilder().maximumSize(schemaCacheSize)
            .expireAfterAccess(schemaCacheExpiryInMilliSecs, TimeUnit.MILLISECONDS)
            .build(new CacheLoader<SchemaVersionKey, SchemaVersionInfo>() {
                @Override/*from   ww  w  .ja va 2 s . c om*/
                public SchemaVersionInfo load(SchemaVersionKey key) throws Exception {
                    return schemaRetriever.retrieveSchemaVersion(key);
                }
            });

}

From source file:com.coredot.jdebugconsole.RateStat.java

public RateStat(String name, int seconds) {
    this.name = name;
    this.seconds = seconds;
    cache = new Cache(
            CacheBuilder.newBuilder().expireAfterWrite(seconds, TimeUnit.SECONDS).build(new RateCacheLoader()));
}

From source file:org.opendaylight.controller.md.sal.binding.impl.BindingMountPointAdapter.java

public BindingMountPointAdapter(final BindingToNormalizedNodeCodec codec, final DOMMountPoint domMountPoint) {
    identifier = codec.getCodecRegistry().fromYangInstanceIdentifier(domMountPoint.getIdentifier());
    services = CacheBuilder.newBuilder().build(new BindingDOMAdapterLoader(codec) {

        @Override//from www  .  j  a  v  a2  s.  c om
        protected DOMService getDelegate(Class<? extends DOMService> reqDeleg) {
            return domMountPoint.getService(reqDeleg).orNull();
        }
    });
}

From source file:org.wso2.carbon.databridge.core.internal.authentication.session.SessionCache.java

public SessionCache(int expirationTimeInMinutes) {
    cache = CacheBuilder.newBuilder().expireAfterWrite(expirationTimeInMinutes, TimeUnit.MINUTES)
            .build(CacheLoader.from(new SessionFunction()));
}

From source file:org.eclipse.emf.compare.match.DefaultEqualityHelperFactory.java

/**
 * Default constructor.
 */
public DefaultEqualityHelperFactory() {
    this(CacheBuilder.newBuilder().maximumSize(DefaultMatchEngine.DEFAULT_EOBJECT_URI_CACHE_MAX_SIZE));
}

From source file:com.spotify.metrics.guava.GuavaCache.java

public static MetricIdCache.Any setup(final Setup setup) {
    return MetricIdCache.builder().cacheBuilder(new MetricIdCache.CacheBuilder() {
        @Override// w  ww  . j a  v  a  2s .co m
        public <T> MetricIdCache.Cache<T> build(final MetricIdCache.Loader<T> loader) {
            final Cache<T, MetricId> cache = setup.setup(CacheBuilder.newBuilder()).build();
            return new GuavaCache<T>(loader, cache);
        }
    });
}

From source file:org.gradle.tooling.internal.provider.JarCache.java

public JarCache() {
    this.cachedFiles = CacheBuilder.newBuilder().maximumSize(200).build();
}

From source file:fr.inria.corese.tinkerpop.mapper.TinkerpopToCorese.java

public TinkerpopToCorese(Graph g) {
    edge = new EdgeGeneric();
    this.cache = CacheBuilder.newBuilder().maximumSize(100).expireAfterAccess(100, TimeUnit.DAYS)
            .build(new CacheLoader<Edge, Entity>() {
                IDatatype name, predicate;

                @Override/*w ww  . j  ava  2 s  . c  o  m*/
                public Entity load(Edge e) throws Exception {
                    //String graph = e.value(EDGE_G);
                    if (name == null) {
                        name = DatatypeMap.createResource((String) e.value(EDGE_G));
                    }
                    String property = (String) e.value(EDGE_P);
                    if (predicate == null || !predicate.getLabel().equals(property)) {
                        predicate = DatatypeMap.createResource(property);
                    }
                    Entity result = EdgeQuad.create(name, unmapNode(e.outVertex()), predicate,
                            unmapNode(e.inVertex()));
                    return result;
                }
            });
}

From source file:com.hpe.caf.worker.core.ResponseStreamCache.java

public ResponseStreamCache() {
    this.cacheImpl = CacheBuilder.newBuilder().maximumSize(CACHE_MAX_SIZE)
            .expireAfterWrite(CACHE_ITEM_LIFETIME_SECS, TimeUnit.SECONDS).build();
}

From source file:com.streamsets.datacollector.util.LockCache.java

@Inject
public LockCache() {
    cache = CacheBuilder.newBuilder().weakValues().build(new CacheLoader<K, Object>() {
        @Override// www .  ja va  2 s. c  om
        public Object load(K key) {
            return new Object();
        }
    });
}