|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap java.util.HashMap java.util.LinkedHashMap groovyx.gpars.memoize.LRUProtectionStorage
public final class LRUProtectionStorage extends java.util.LinkedHashMap
Protects stored resources from eviction from memory following the LRU (Last Recently Used) strategy. If the maximum size has been reached all newly added elements will cause the oldest element to be removed from the storage in order not to exceed the maximum capacity. The touch method can be used to renew an element and move it to the from the LRU queue.
Field Summary | |
---|---|
private int |
maxSize
|
private static long |
serialVersionUID
|
Constructor Summary | |
LRUProtectionStorage(int maxSize)
|
Method Summary | |
---|---|
java.lang.Object
|
clone()
Performs a shallow clone |
protected boolean
|
removeEldestEntry(java.util.Map$Entry eldest)
|
void
|
touch(java.lang.Object key, java.lang.Object value)
The touch method can be used to renew an element and move it to the from of the LRU queue. |
Methods inherited from class java.util.LinkedHashMap | |
---|---|
java.util.LinkedHashMap#get(java.lang.Object), java.util.LinkedHashMap#clear(), java.util.LinkedHashMap#containsValue(java.lang.Object), java.util.LinkedHashMap#put(java.lang.Object, java.lang.Object), java.util.LinkedHashMap#values(), java.util.LinkedHashMap#clone(), java.util.LinkedHashMap#isEmpty(), java.util.LinkedHashMap#entrySet(), java.util.LinkedHashMap#putAll(java.util.Map), java.util.LinkedHashMap#size(), java.util.LinkedHashMap#remove(java.lang.Object), java.util.LinkedHashMap#keySet(), java.util.LinkedHashMap#containsKey(java.lang.Object), java.util.LinkedHashMap#equals(java.lang.Object), java.util.LinkedHashMap#toString(), java.util.LinkedHashMap#hashCode(), java.util.LinkedHashMap#wait(long), java.util.LinkedHashMap#wait(), java.util.LinkedHashMap#wait(long, int), java.util.LinkedHashMap#getClass(), java.util.LinkedHashMap#notify(), java.util.LinkedHashMap#notifyAll() |
Methods inherited from class java.util.HashMap | |
---|---|
java.util.HashMap#get(java.lang.Object), java.util.HashMap#put(java.lang.Object, java.lang.Object), java.util.HashMap#values(), java.util.HashMap#clone(), java.util.HashMap#clear(), java.util.HashMap#isEmpty(), java.util.HashMap#entrySet(), java.util.HashMap#putAll(java.util.Map), java.util.HashMap#size(), java.util.HashMap#remove(java.lang.Object), java.util.HashMap#keySet(), java.util.HashMap#containsKey(java.lang.Object), java.util.HashMap#containsValue(java.lang.Object), java.util.HashMap#equals(java.lang.Object), java.util.HashMap#toString(), java.util.HashMap#hashCode(), java.util.HashMap#wait(long), java.util.HashMap#wait(), java.util.HashMap#wait(long, int), java.util.HashMap#getClass(), java.util.HashMap#notify(), java.util.HashMap#notifyAll() |
Field Detail |
---|
private final int maxSize
private static final long serialVersionUID
Constructor Detail |
---|
public LRUProtectionStorage(int maxSize)
Method Detail |
---|
@SuppressWarnings({"EmptyMethod"}) @Override public java.lang.Object clone()
@Override protected boolean removeEldestEntry(@SuppressWarnings("rawtypes") java.util.Map$Entry eldest)
@SuppressWarnings({"SynchronizedMethod"}) public void touch(java.lang.Object key, java.lang.Object value)
key
- The key of the element to renewvalue
- A value to newly associate with the key
Copyright © 2008–2012 Václav Pech. All Rights Reserved.