@ThreadSafe public class StampedCommonCache<K, V> extends Object implements EvictableCache, ValueConvertable, Serializable
Represents a simple key-value cache, which is thread safe and backed by a Map instance. StampedCommonCache has better performance than ConcurrentCommonCache, but it is not reentrant, in other words, it may cause deadlock if getAndPut(Object, MemoizeCache.ValueProvider) or getAndPut(Object, MemoizeCache.ValueProvider, boolean) is called recursively: readlock -> upgrade to writelock -> readlock (fails to get and waits forever)
K
- type of the keysV
- type of the valuesConstructor and description |
---|
StampedCommonCache
() Constructs a cache with unlimited size |
StampedCommonCache
(int initialCapacity, int maxSize, EvictionStrategy evictionStrategy) Constructs a cache with limited size |
StampedCommonCache
(int initialCapacity, int maxSize) Constructs a LRU cache with the specified initial capacity and max size. |
StampedCommonCache
(int maxSize) Constructs a LRU cache with the default initial capacity(16) |
StampedCommonCache
(Map<K, V> map) Constructs a cache backed by the specified Map instance |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
cleanUpNullReferences() {@inheritDoc} |
|
public Map<K, V> |
clearAll() {@inheritDoc} |
|
public boolean |
containsKey(Object key) {@inheritDoc} |
|
public boolean |
containsValue(Object value) |
|
public Object |
convertValue(V value) {@inheritDoc} |
|
public Set<Entry<K, V>> |
entrySet() |
|
public V |
get(Object key) {@inheritDoc} |
|
public V |
getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) {@inheritDoc} |
|
public V |
getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider, boolean shouldCache) |
|
public boolean |
isEmpty() |
|
public Set<K> |
keySet() |
|
public Set<K> |
keys() {@inheritDoc} |
|
public V |
put(K key, V value) {@inheritDoc} |
|
public void |
putAll(Map<? extends K, ? extends V> m) |
|
public V |
remove(Object key) {@inheritDoc} |
|
public int |
size() {@inheritDoc} |
|
public Collection<V> |
values() {@inheritDoc} |
Constructs a cache with unlimited size
Constructs a cache with limited size
initialCapacity
- initial capacity of the cachemaxSize
- max size of the cacheevictionStrategy
- LRU or FIFO, see EvictableCache.EvictionStrategyConstructs a LRU cache with the specified initial capacity and max size. The LRU cache is slower than LRUCache
initialCapacity
- initial capacity of the LRU cachemaxSize
- max size of the LRU cacheConstructs a LRU cache with the default initial capacity(16)
maxSize
- max size of the LRU cache{@inheritDoc}
{@inheritDoc}
{@inheritDoc}
{@inheritDoc}
{@inheritDoc}
Copyright © 2003-2024 The Apache Software Foundation. All rights reserved.