@ThreadSafe
public final class LRUCache<K, V>
extends Object
implements MemoizeCache
A cache backed by a ConcurrentLinkedHashMap
| Constructor and description |
|---|
LRUCache(int maxCacheSize)Creates an LRU cache with the supplied maximum size. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
cleanUpNullReferences()Remove all entries holding SoftReferences to gc-evicted objects. |
|
public V |
get(K key)Returns the value associated with the supplied key. |
|
public V |
getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider)Try to get the value from cache. |
|
public V |
put(K key, V value)Associates the specified value with the specified key in this cache. |
Creates an LRU cache with the supplied maximum size.
maxCacheSize - the maximum number of cached entriesRemove all entries holding SoftReferences to gc-evicted objects.
Returns the value associated with the supplied key.
key - the key to look upnull if none is presentTry to get the value from cache. If not found, create the value by MemoizeCache.ValueProvider and put it into the cache, at last return the value. The operation is completed atomically.
key - the key to look upvalueProvider - provide the value if the associated value not foundAssociates the specified value with the specified key in this cache.
key - the key with which the value is to be associatedvalue - the value to cachekey, or nullCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.