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.plista.kornakapi.core.storage.CandidateCacheStorageDecorator.java

public CandidateCacheStorageDecorator(Storage delegate) {
    this.delegate = delegate;
    cache = CacheBuilder.newBuilder().maximumSize(100).build();
}

From source file:org.apigw.authserver.svc.impl.CachingPermissionServices.java

@PostConstruct
protected void init() {
    scopeCache = CacheBuilder.newBuilder().expireAfterWrite(expireAfterWriteTime, expireAfterWriteTimeUnit)
            .build(new PermissionByNameCacheLoader(permissionServices));
}

From source file:com.facebook.buck.rules.keys.ReflectiveRuleKeyBuilderFactory.java

public ReflectiveRuleKeyBuilderFactory() {
    knownFields = CacheBuilder.newBuilder().build(new ReflectiveAlterKeyLoader());
    knownRules = CacheBuilder.newBuilder().weakKeys().build(new CacheLoader<BuildRule, RuleKey>() {
        @Override/*  w w w.ja va2s .  c o  m*/
        public RuleKey load(BuildRule key) throws Exception {
            return newInstance(key).build();
        }
    });
}

From source file:org.opendaylight.yangtools.yang.model.repo.util.InMemorySchemaSourceCache.java

public static <R extends SchemaSourceRepresentation> InMemorySchemaSourceCache<R> createSoftCache(
        final SchemaSourceRegistry consumer, final Class<R> representation, final long lifetime,
        final TimeUnit units) {
    return new InMemorySchemaSourceCache<>(consumer, representation,
            CacheBuilder.newBuilder().softValues().expireAfterAccess(lifetime, units));
}

From source file:org.gradle.ide.xcode.internal.xcodeproj.PBXGroup.java

public PBXGroup(String name, @Nullable String path, SourceTree sourceTree) {
    super(name, path, sourceTree);

    sortPolicy = SortPolicy.BY_NAME;/*from ww  w  . ja  v  a2 s .c  o m*/
    children = Lists.newArrayList();

    childGroupsByName = CacheBuilder.newBuilder().build(new CacheLoader<String, PBXGroup>() {
        @Override
        public PBXGroup load(String key) throws Exception {
            PBXGroup group = new PBXGroup(key, null, SourceTree.GROUP);
            children.add(group);
            return group;
        }
    });
}

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

public FsItemsVaultCacheImpl(final LockProvider lockProvider) {
    locks = CacheBuilder.newBuilder().initialCapacity(2000).softValues()
            .expireAfterAccess(ConstantValues.fsItemCacheIdleTimeSecs.getLong(), TimeUnit.SECONDS)
            .build(new CacheLoader<RepoPath, LockWrapper>() {
                @Override//from  www  .  ja v  a  2s.co  m
                public LockWrapper load(RepoPath key) throws Exception {
                    return lockProvider.getLock(key);
                }
            });
}

From source file:br.com.objectos.office.core.OfficeRuntime.java

OfficeRuntime() {
    officeCache = CacheBuilder.newBuilder().maximumSize(1).build(new OfficeCacheLoader());
}

From source file:ninja.leaping.permissionsex.data.RankLadderCache.java

public RankLadderCache(final RankLadderCache existing, final DataStore dataStore) {
    this.dataStore = dataStore;
    cache = CacheBuilder.newBuilder().maximumSize(512).build(new CacheLoader<String, RankLadder>() {
        @Override//from  w  ww. j  a  va 2  s  .  c  o m
        public RankLadder load(String identifier) throws Exception {
            return dataStore.getRankLadder(identifier, clearListener(identifier));
        }
    });
    if (existing != null) {
        listeners = existing.listeners;
        existing.cache.asMap().forEach((k, old) -> listeners.call(k, get(k, null)));
    } else {
        listeners = new CacheListenerHolder<>();
    }
}

From source file:fr.amapj.service.services.mailer.MailerCounter.java

private MailerCounter() {
    cache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS)
            .build(new CacheLoader<MailKey, MailCount>() {
                public MailCount load(MailKey key) {
                    return new MailCount();
                }//from ww w . ja va  2s  .co m
            });
}

From source file:co.cask.cdap.internal.app.runtime.flow.SchemaCache.java

/**
 * Creates the schema cache with a set of know schemas.
 *
 * @param schemas Set of known schemas//www  .j  a  va2 s . co m
 */
public SchemaCache(Iterable<Schema> schemas, ClassLoader classLoader) {

    // TODO: Later on we should use ClassLoader.getResource
    final Map<SchemaHash, Schema> schemaMap = Maps.newHashMap();
    for (Schema schema : schemas) {
        schemaMap.put(schema.getSchemaHash(), schema);
    }

    cache = CacheBuilder.newBuilder().build(new CacheLoader<SchemaHash, Schema>() {
        @Override
        public Schema load(SchemaHash key) throws Exception {
            Schema schema = schemaMap.get(key);
            Preconditions.checkNotNull(schema);
            // TODO: Load from classloader
            return schema;
        }
    });
}