K - types of keys used in the cacheV - types of values used in the cachepublic static class EvictableCache.Builder<K,V> extends Object
EvictableCache.| Constructor | Description |
|---|---|
Builder() |
| Modifier and Type | Method | Description |
|---|---|---|
<K,V> EvictableCache<K,V> |
build() |
Build a new instance of the cache configured from this builder.
|
EvictableCache.Builder<K,V> |
evictor(BiFunction<K,V,Boolean> evictor) |
Configure evictor to check if a records is still valid.
|
EvictableCache.Builder<K,V> |
evictSchedule(long evictDelay,
long evictPeriod,
TimeUnit evictTimeUnit) |
Configure eviction scheduling.
|
EvictableCache.Builder<K,V> |
maxSize(long cacheMaxSize) |
Configure maximal cache size.
|
EvictableCache.Builder<K,V> |
parallelismThreshold(long parallelismThreshold) |
Configure parallelism threshold.
|
EvictableCache.Builder<K,V> |
timeout(long timeout,
TimeUnit timeoutUnit) |
Configure record timeout since last modification.
|
public <K,V> EvictableCache<K,V> build()
K - types of keys used in the cacheV - types of values used in the cachepublic EvictableCache.Builder<K,V> timeout(long timeout, TimeUnit timeoutUnit)
timeout - timeout valuetimeoutUnit - timeout unitpublic EvictableCache.Builder<K,V> maxSize(long cacheMaxSize)
cacheMaxSize - maximal number of records to store in the cachepublic EvictableCache.Builder<K,V> evictSchedule(long evictDelay, long evictPeriod, TimeUnit evictTimeUnit)
evictDelay - delay from the creation of the cache to first evictionevictPeriod - how often to evict recordsevictTimeUnit - time unit to use for these valuespublic EvictableCache.Builder<K,V> parallelismThreshold(long parallelismThreshold)
parallelismThreshold - see ConcurrentHashMap.forEachKey(long, Consumer)public EvictableCache.Builder<K,V> evictor(BiFunction<K,V,Boolean> evictor)
ConcurrentHashMap.forEachKey(long, Consumer).
This is also called during all get and remove operations to only return valid records.evictor - evictor to use, return true for records that should be evicted, false for records
that should stay in cacheCopyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.