Top Description Inners Fields Constructors Methods
com.github.benmanes.caffeine.cache

pack-priv final Class UnboundedLocalCache<K, V>

extends Object
implements LocalCache<K, V>
Class Inheritance
All Implemented Interfaces
com.github.benmanes.caffeine.cache.LocalCache, java.util.concurrent.ConcurrentMap, java.util.Map
Annotations
@SuppressWarnings:serial
Static Imports
com.github.benmanes.caffeine.cache.Caffeine.calculateHashMapCapacity, .LocalLoadingCache.newBulkMappingFunction, .LocalLoadingCache.newMappingFunction, java.util.Objects.requireNonNull, java.util.function.Function.identity

An in-memory cache that has no capabilities for bounding the map. This implementation provides a lightweight wrapper on top of ConcurrentHashMap.
Author
[email protected] (Ben Manes)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
UnboundedLocalCache.EntryIterator<K, V>

An adapter to safely externalize the entry iterator.

pack-priv static class
UnboundedLocalCache.EntrySetView<K, V>

An adapter to safely externalize the entries.

pack-priv static class
UnboundedLocalCache.EntrySpliterator<K, V>

An adapter to safely externalize the entry spliterator.

pack-priv static class
UnboundedLocalCache.KeyIterator<K>

An adapter to safely externalize the key iterator.

pack-priv static class
UnboundedLocalCache.KeySetView<K>

An adapter to safely externalize the keys.

pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
UnboundedLocalCache.UnboundedPolicy<K, V>

An eviction policy that supports no boundings.

pack-priv static class
UnboundedLocalCache.ValuesIterator<K, V>

An adapter to safely externalize the value iterator.

pack-priv static class
UnboundedLocalCache.ValuesView<K, V>

An adapter to safely externalize the values.

Field Summary

Modifier and TypeField and Description
pack-priv final ConcurrentHashMap<K, V>
pack-priv @Nullable Set<Map.Entry<K, V>>
pack-priv final Executor
pack-priv final boolean
pack-priv final boolean
pack-priv @Nullable Set<K>
pack-priv static final System.Logger
pack-priv static final VarHandle
pack-priv volatile @Nullable ConcurrentMap<Object, CompletableFuture<?>>
pack-priv final @Nullable RemovalListener<K, V>
pack-priv final StatsCounter
pack-priv final Ticker
pack-priv @Nullable Collection<V>

Constructor Summary

AccessConstructor and Description
pack-priv
UnboundedLocalCache(Caffeine<? super K, ? super V> builder, boolean isAsync)

Method Summary

Modifier and TypeMethod and Description
public void
public void
clear()

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).
public V
compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, @Nullable Expiry<? super K, ? super V> expiry, boolean recordLoad, boolean recordLoadFailure)

public V
computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, boolean recordStats, boolean recordLoad)

Implements com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent.

See ConcurrentMap#computeIfAbsent.
public @Nullable V
computeIfPresent(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the remapping function to compute a value
remappingFunction
)

Overrides default java.util.concurrent.ConcurrentMap.computeIfPresent.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.
public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.
public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.
pack-priv void
discardRefresh(Object keyReference)

Invalidate the in-flight refresh.

public Set<Map.Entry<K, V>>
entrySet()

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public boolean
equals(Object
object to be compared for equality with this map
o
)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.
public long
public Executor
executor()

Implements com.github.benmanes.caffeine.cache.LocalCache.executor.

Returns the Executor used by this cache.
public Expiry<K, V>
expiry()

Implements com.github.benmanes.caffeine.cache.LocalCache.expiry.

Returns the Expiry used by this cache.
public void
forEach(BiConsumer<? super K, ? super V>
The action to be performed for each entry
action
)

Overrides default java.util.concurrent.ConcurrentMap.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
public @Nullable V
get(Object
the key whose associated value is to be returned
key
)

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public Map<K, V>
public @Nullable V
public @Nullable V
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.
private boolean
public boolean
isAsync()

Implements com.github.benmanes.caffeine.cache.LocalCache.isAsync.

Returns whether this cache is asynchronous.
public boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.
public boolean
isPendingEviction(K key)

Implements com.github.benmanes.caffeine.cache.LocalCache.isPendingEviction.

Returns whether an absent entry has expired or has been reference collected but has not yet been removed from the cache.
public boolean
isRecordingStats()

Implements com.github.benmanes.caffeine.cache.LocalCache.isRecordingStats.

Returns whether this cache has statistics enabled.
public Set<K>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.
public V
merge(K
key with which the resulting value is to be associated
key
,
V
the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
value
,
BiFunction<? super V, ? super V, ? extends V>
the remapping function to recompute a value if present
remappingFunction
)

Overrides default java.util.concurrent.ConcurrentMap.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value.
public void
public @Nullable V
put(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public void
putAll(Map<? extends K, ? extends V>
mappings to be stored in this map
map
)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).
public @Nullable V
putIfAbsent(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Implements java.util.concurrent.ConcurrentMap.putIfAbsent.

If the specified key is not already associated with a value, associates it with the given value.
public Object
referenceKey(K key)

Implements com.github.benmanes.caffeine.cache.LocalCache.referenceKey.

Returns the reference key.
public ConcurrentMap<Object, CompletableFuture<?>>
refreshes()

Implements com.github.benmanes.caffeine.cache.LocalCache.refreshes.

Returns the map of in-flight refresh operations.
pack-priv V

Returns:

the new value associated with the specified key, or null if none
remap
(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the function to compute a value
remappingFunction
)

A Map#compute(Object, BiFunction) that does not directly record any cache statistics.

public @Nullable V
remove(Object
key whose mapping is to be removed from the map
key
)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).
public boolean
remove(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
value
)

Implements java.util.concurrent.ConcurrentMap.remove.

Removes the entry for a key only if currently mapped to a given value.
public @Nullable V
replace(K
key with which the specified value is associated
key
,
V
value to be associated with the specified key
value
)

Implements java.util.concurrent.ConcurrentMap.replace.

Replaces the entry for a key only if currently mapped to some value.
public boolean
replace(K
key with which the specified value is associated
key
,
V
value expected to be associated with the specified key
oldValue
,
V
value to be associated with the specified key
newValue
)

Implements java.util.concurrent.ConcurrentMap.replace.

Replaces the entry for a key only if currently mapped to a given value.
public boolean
replace(K key, V oldValue, V newValue, boolean shouldDiscardRefresh)

Implements com.github.benmanes.caffeine.cache.LocalCache.replace.

See ConcurrentMap#replace(K, K, V).
public void
replaceAll(BiFunction<? super K, ? super V, ? extends V>
the function to apply to each entry
function
)

Overrides default java.util.concurrent.ConcurrentMap.replaceAll.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.
public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
public StatsCounter
public Ticker
statsTicker()

Implements com.github.benmanes.caffeine.cache.LocalCache.statsTicker.

Returns the Ticker used by this cache for statistics.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Collection<V>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait