Class UnboundedLocalCache<K,V>
java.lang.Object
com.github.benmanes.caffeine.cache.UnboundedLocalCache<K,V>
- All Implemented Interfaces:
LocalCache<K,V>, ConcurrentMap<K, V>, Map<K, V>
An in-memory cache that has no capabilities for bounding the map. This implementation provides
a lightweight wrapper on top of
ConcurrentHashMap.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classAn adapter to safely externalize the entry iterator.(package private) static final classAn adapter to safely externalize the entries.(package private) static final classAn adapter to safely externalize the entry spliterator.(package private) static final classAn adapter to safely externalize the key iterator.(package private) static final classAn adapter to safely externalize the keys.(package private) static final class(package private) static final class(package private) static final class(package private) static class(package private) static final classAn eviction policy that supports no boundings.(package private) static final classAn adapter to safely externalize the value iterator.(package private) static final classAn adapter to safely externalize the values. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ConcurrentHashMap<K, V> (package private) final Executor(package private) final boolean(package private) final @Nullable RemovalListener<K, V> (package private) final StatsCounter(package private) final Ticker(package private) @Nullable Collection<V> (package private) final CacheWriter<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanUp()SeeCache.cleanUp().voidclear()compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, boolean recordMiss, boolean recordLoad, boolean recordLoadFailure) computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, boolean recordStats, boolean recordLoad) @Nullable VcomputeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanlongexecutor()Returns theExecutorused by this cache.Returns theTickerused by this cache for expiration.voidforEach(BiConsumer<? super K, ? super V> action) @Nullable VgetAllPresent(Iterable<?> keys) @Nullable VgetIfPresent(Object key, boolean recordStats) @Nullable VgetIfPresentQuietly(Object key, long[] writeTime) inthashCode()booleanReturns whether this cache notifies when an entry is removed.booleanReturns whether the cache captures the write time of the entry.booleanisEmpty()booleanReturns whether this cache has statistics enabled.keySet()voidnotifyRemoval(@Nullable K key, @Nullable V value, RemovalCause cause) Asynchronously sends a removal notification to the listener.@Nullable V@Nullable Vvoid@Nullable VputIfAbsent(K key, V value) (package private) VAMap.compute(Object, BiFunction)that does not directly record any cache statistics.Returns theRemovalListenerused by this cache.@Nullable Vboolean@Nullable VbooleanvoidreplaceAll(BiFunction<? super K, ? super V, ? extends V> function) intsize()Returns theStatsCounterused by this cache.Returns theTickerused by this cache for statistics.toString()values()Methods inherited from interface ConcurrentMap
getOrDefaultMethods inherited from interface LocalCache
compute, computeIfAbsent, invalidateAll, statsAware, statsAware, statsAware
-
Field Details
-
removalListener
-
data
-
statsCounter
-
isRecordingStats
final boolean isRecordingStats -
writer
-
executor
-
ticker
-
keySet
-
values
-
entrySet
-
-
Constructor Details
-
UnboundedLocalCache
-
-
Method Details
-
hasWriteTime
public boolean hasWriteTime()Description copied from interface:LocalCacheReturns whether the cache captures the write time of the entry.- Specified by:
hasWriteTimein interfaceLocalCache<K,V>
-
getIfPresent
Description copied from interface:LocalCacheSeeCache.getIfPresent(Object). This method differs by accepting a parameter of whether to record the hit and miss statistics based on the success of this operation.- Specified by:
getIfPresentin interfaceLocalCache<K,V>
-
getIfPresentQuietly
Description copied from interface:LocalCacheSeeCache.getIfPresent(Object). This method differs by not recording the access with the statistics nor the eviction policy, and populates the write time if known.- Specified by:
getIfPresentQuietlyin interfaceLocalCache<K,V>
-
estimatedSize
public long estimatedSize()Description copied from interface:LocalCache- Specified by:
estimatedSizein interfaceLocalCache<K,V>
-
getAllPresent
Description copied from interface:LocalCache- Specified by:
getAllPresentin interfaceLocalCache<K,V>
-
cleanUp
public void cleanUp()Description copied from interface:LocalCacheSeeCache.cleanUp().- Specified by:
cleanUpin interfaceLocalCache<K,V>
-
statsCounter
Description copied from interface:LocalCacheReturns theStatsCounterused by this cache.- Specified by:
statsCounterin interfaceLocalCache<K,V>
-
hasRemovalListener
public boolean hasRemovalListener()Description copied from interface:LocalCacheReturns whether this cache notifies when an entry is removed.- Specified by:
hasRemovalListenerin interfaceLocalCache<K,V>
-
removalListener
Description copied from interface:LocalCacheReturns theRemovalListenerused by this cache.- Specified by:
removalListenerin interfaceLocalCache<K,V>
-
notifyRemoval
Description copied from interface:LocalCacheAsynchronously sends a removal notification to the listener.- Specified by:
notifyRemovalin interfaceLocalCache<K,V>
-
isRecordingStats
public boolean isRecordingStats()Description copied from interface:LocalCacheReturns whether this cache has statistics enabled.- Specified by:
isRecordingStatsin interfaceLocalCache<K,V>
-
executor
Description copied from interface:LocalCacheReturns theExecutorused by this cache.- Specified by:
executorin interfaceLocalCache<K,V>
-
expirationTicker
Description copied from interface:LocalCacheReturns theTickerused by this cache for expiration.- Specified by:
expirationTickerin interfaceLocalCache<K,V>
-
statsTicker
Description copied from interface:LocalCacheReturns theTickerused by this cache for statistics.- Specified by:
statsTickerin interfaceLocalCache<K,V>
-
forEach
-
replaceAll
- Specified by:
replaceAllin interfaceConcurrentMap<K,V> - Specified by:
replaceAllin interfaceMap<K,V>
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, boolean recordStats, boolean recordLoad) Description copied from interface:LocalCacheSeeConcurrentMap.computeIfAbsent(K, Function). This method differs by accepting parameters indicating how to record statistics.- Specified by:
computeIfAbsentin interfaceLocalCache<K,V>
-
computeIfPresent
public @Nullable V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) - Specified by:
computeIfPresentin interfaceConcurrentMap<K,V> - Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, boolean recordMiss, boolean recordLoad, boolean recordLoadFailure) Description copied from interface:LocalCacheSeeConcurrentMap.compute(K, BiFunction). This method differs by accepting parameters indicating whether to record miss and load statistics based on the success of this operation.- Specified by:
computein interfaceLocalCache<K,V>
-
merge
-
remap
AMap.compute(Object, BiFunction)that does not directly record any cache statistics.- Parameters:
key- key with which the specified value is to be associatedremappingFunction- the function to compute a value- Returns:
- the new value associated with the specified key, or null if none
-
isEmpty
-
size
-
clear
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
put
Description copied from interface:LocalCacheSeeCache.put(Object, Object). This method differs by allowing the operation to not notify the writer when an entry was inserted or updated.- Specified by:
putin interfaceLocalCache<K,V>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
putAll
-
remove
-
remove
-
replace
-
replace
-
equals
-
hashCode
-
toString
-
keySet
-
values
-
entrySet
-