public final class LRUCache<K,V>
extends java.util.AbstractMap<K,V>
implements java.util.concurrent.ConcurrentMap<K,V>, java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
LRUCache.Builder<K,V>
A builder that creates
ConcurrentLinkedHashMap instances. |
| Modifier and Type | Method and Description |
|---|---|
java.util.Set<K> |
ascendingKeySet()
Returns a unmodifiable snapshot
Set view of the keys contained in
this map. |
java.util.Set<K> |
ascendingKeySetWithLimit(int limit)
Returns an unmodifiable snapshot
Set view of the keys contained in
this map. |
java.util.Map<K,V> |
ascendingMap()
Returns an unmodifiable snapshot
Map view of the mappings contained
in this map. |
java.util.Map<K,V> |
ascendingMapWithLimit(int limit)
Returns an unmodifiable snapshot
Map view of the mappings contained
in this map. |
long |
capacity()
Retrieves the maximum weighted capacity of the map.
|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<K> |
descendingKeySet()
Returns an unmodifiable snapshot
Set view of the keys contained in
this map. |
java.util.Set<K> |
descendingKeySetWithLimit(int limit)
Returns an unmodifiable snapshot
Set view of the keys contained in
this map. |
java.util.Map<K,V> |
descendingMap()
Returns an unmodifiable snapshot
Map view of the mappings contained
in this map. |
java.util.Map<K,V> |
descendingMapWithLimit(int limit)
Returns an unmodifiable snapshot
Map view of the mappings contained
in this map. |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
V |
getQuietly(java.lang.Object key)
Returns the value to which the specified key is mapped, or
null
if this map contains no mapping for the key. |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
V |
put(K key,
V value) |
V |
putIfAbsent(K key,
V value) |
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
void |
setCapacity(long capacity)
Sets the maximum weighted capacity of the map and eagerly evicts entries
until it shrinks to the appropriate size.
|
int |
size() |
java.util.Collection<V> |
values() |
long |
weightedSize()
Returns the weighted size of this map.
|
finalize, getClass, notify, notifyAll, wait, wait, waitpublic long capacity()
public void setCapacity(long capacity)
capacity - the maximum weighted capacity of the mapjava.lang.IllegalArgumentException - if the capacity is negativepublic boolean isEmpty()
public int size()
public long weightedSize()
public void clear()
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public V get(java.lang.Object key)
public V getQuietly(java.lang.Object key)
null
if this map contains no mapping for the key. This method differs from
get(Object) in that it does not record the operation with the
page replacement policy.key - the key whose associated value is to be returnednull if this map contains no mapping for the keyjava.lang.NullPointerException - if the specified key is nullpublic V remove(java.lang.Object key)
public boolean remove(java.lang.Object key,
java.lang.Object value)
public java.util.Set<K> keySet()
public java.util.Set<K> ascendingKeySet()
Set view of the keys contained in
this map. The set's iterator returns the keys whose order of iteration is
the ascending order in which its entries are considered eligible for
retention, from the least-likely to be retained to the most-likely.
Beware that, unlike in keySet(), obtaining the set is NOT
a constant-time operation. Because of the asynchronous nature of the page
replacement policy, determining the retention ordering requires a traversal
of the keys.
public java.util.Set<K> ascendingKeySetWithLimit(int limit)
Set view of the keys contained in
this map. The set's iterator returns the keys whose order of iteration is
the ascending order in which its entries are considered eligible for
retention, from the least-likely to be retained to the most-likely.
Beware that, unlike in keySet(), obtaining the set is NOT
a constant-time operation. Because of the asynchronous nature of the page
replacement policy, determining the retention ordering requires a traversal
of the keys.
limit - the maximum size of the returned setjava.lang.IllegalArgumentException - if the limit is negativepublic java.util.Set<K> descendingKeySet()
Set view of the keys contained in
this map. The set's iterator returns the keys whose order of iteration is
the descending order in which its entries are considered eligible for
retention, from the most-likely to be retained to the least-likely.
Beware that, unlike in keySet(), obtaining the set is NOT
a constant-time operation. Because of the asynchronous nature of the page
replacement policy, determining the retention ordering requires a traversal
of the keys.
public java.util.Set<K> descendingKeySetWithLimit(int limit)
Set view of the keys contained in
this map. The set's iterator returns the keys whose order of iteration is
the descending order in which its entries are considered eligible for
retention, from the most-likely to be retained to the least-likely.
Beware that, unlike in keySet(), obtaining the set is NOT
a constant-time operation. Because of the asynchronous nature of the page
replacement policy, determining the retention ordering requires a traversal
of the keys.
limit - the maximum size of the returned setjava.lang.IllegalArgumentException - if the limit is negativepublic java.util.Collection<V> values()
public java.util.Map<K,V> ascendingMap()
Map view of the mappings contained
in this map. The map's collections return the mappings whose order of
iteration is the ascending order in which its entries are considered
eligible for retention, from the least-likely to be retained to the
most-likely.
Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
public java.util.Map<K,V> ascendingMapWithLimit(int limit)
Map view of the mappings contained
in this map. The map's collections return the mappings whose order of
iteration is the ascending order in which its entries are considered
eligible for retention, from the least-likely to be retained to the
most-likely.
Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
limit - the maximum size of the returned mapjava.lang.IllegalArgumentException - if the limit is negativepublic java.util.Map<K,V> descendingMap()
Map view of the mappings contained
in this map. The map's collections return the mappings whose order of
iteration is the descending order in which its entries are considered
eligible for retention, from the most-likely to be retained to the
least-likely.
Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
public java.util.Map<K,V> descendingMapWithLimit(int limit)
Map view of the mappings contained
in this map. The map's collections return the mappings whose order of
iteration is the descending order in which its entries are considered
eligible for retention, from the most-likely to be retained to the
least-likely.
Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
limit - the maximum size of the returned mapjava.lang.IllegalArgumentException - if the limit is negative