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.streamline.streams.runtime.splitjoin.EventGroup.java

public EventGroup(String groupId, String dataSourceId, long eventExpiryInterval) {
    this.groupId = groupId;
    this.dataSourceId = dataSourceId;
    this.eventExpiryInterval = eventExpiryInterval;

    splitEvents = CacheBuilder.newBuilder().expireAfterWrite(eventExpiryInterval, TimeUnit.MILLISECONDS)
            .build();//from w  ww  .  j av a2  s . c om
}

From source file:azkaban.server.session.SessionCache.java

/**
 * Constructor taking global props./*from   w ww.  j a va 2 s.  c o m*/
 *
 * @param props
 */
public SessionCache(Props props) {
    cache = CacheBuilder.newBuilder().maximumSize(props.getInt("max.num.sessions", MAX_NUM_SESSIONS))
            .expireAfterAccess(props.getLong("session.time.to.live", SESSION_TIME_TO_LIVE),
                    TimeUnit.MILLISECONDS)
            .build();
}

From source file:org.jboss.weld.annotated.slim.SlimAnnotatedTypeStoreImpl.java

public SlimAnnotatedTypeStoreImpl() {
    this.typesByClass = CacheBuilder.newBuilder().build(new CacheLoader<Class<?>, Set<SlimAnnotatedType<?>>>() {
        @Override//from   www . ja v a 2 s.  c  o  m
        public Set<SlimAnnotatedType<?>> load(Class<?> input) {
            return new CopyOnWriteArraySet<SlimAnnotatedType<?>>();
        }
    });
}

From source file:com.proofpoint.bootcamp.PersonStore.java

@Inject
public PersonStore(StoreConfig config, EventClient eventClient) {
    Preconditions.checkNotNull(config, "config must not be null");
    Preconditions.checkNotNull(eventClient, "eventClient is null");

    Cache<String, Person> personCache = CacheBuilder.newBuilder()
            .expireAfterWrite((long) config.getTtl().toMillis(), TimeUnit.MILLISECONDS).build();
    persons = personCache.asMap();//from   w  w w.j a  va 2s . com
    stats = new PersonStoreStats(eventClient);
}

From source file:de.zib.gndms.model.util.GridResourceCache.java

public GridResourceCache(final Class<G> clazz, final EntityManagerFactory emf) {
    this.emf = emf;
    this.clazz = clazz;
    this.cache = CacheBuilder.newBuilder().expireAfterAccess(12, TimeUnit.HOURS).maximumSize(MAX_CACHE_SIZE)
            .initialCapacity(0).build(new GridResourceLoader<G>());
}

From source file:org.nmdp.gl.client.cache.CacheGlClientModule.java

@Provides
@GlClientLocusCache
protected Cache<String, Locus> createLocusCache() {
    return CacheBuilder.newBuilder().initialCapacity(1000).build();
}

From source file:com.reydentx.core.cache.GuavaBaseCache.java

private void initCache() {
    // get cache config
    _maximunSize = RConfig.Instance.getInt(this.getClass(), _name, "maximum-size", _maximunSize);
    _expireAfterAccess = RConfig.Instance.getInt(this.getClass(), _name, "expire-after-access",
            _expireAfterAccess);/*from w w w.  j a v  a  2  s . c o  m*/

    // init cache loader & default value
    CacheLoader<K, V> cacheLoader = declareCacheLoader();
    _emptyValue = declareEmptyValue();

    // init cache
    _innerCache = CacheBuilder.newBuilder().maximumSize(_maximunSize)
            .expireAfterAccess(_expireAfterAccess, TimeUnit.MINUTES).build(cacheLoader);
}

From source file:com.shigengyu.hyperion.cache.TransitionCompensatorCache.java

@Autowired
private TransitionCompensatorCache(final TransitionCompensatorCacheLoader transitionCompensatorCacheLoader) {
    cache = CacheBuilder.newBuilder().build(transitionCompensatorCacheLoader);
}

From source file:com.spotify.dns.CachingLookupFactory.java

CachingLookupFactory(LookupFactory delegate) {
    this.delegate = Preconditions.checkNotNull(delegate, "delegate");
    cacheHolder = new ThreadLocal<Cache<String, Lookup>>() {
        @Override//  ww w. jav  a2  s.com
        protected Cache<String, Lookup> initialValue() {
            return CacheBuilder.newBuilder().build();
        }
    };
}

From source file:org.apache.reef.io.network.naming.NameCache.java

/**
 * Constructs a naming cache/* w  w  w. ja  v a2  s .  c om*/
 *
 * @param timeout a cache entry timeout after access
 */
public NameCache(long timeout) {
    cache = CacheBuilder.newBuilder().expireAfterWrite(timeout, TimeUnit.MILLISECONDS).build();
}