|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<Object,T>
org.simpleframework.xml.util.LimitedCache<T>
public class LimitedCache<T>
The LimitedCache
interface is used to represent a
cache that will store key value pairs. This implementation is
backed by a LinkedHashMap
so that only a specific
number of elements can be stored in the cache at one time.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary | |
---|---|
LimitedCache()
Constructor of the LimitedCache object. |
|
LimitedCache(int capacity)
Constructor of the LimitedCache object. |
Method Summary | |
---|---|
void |
cache(Object key,
T value)
This method is used to insert a key value mapping in to the cache. |
boolean |
contains(Object key)
This is used to determine whether the specified key exists with in the cache. |
T |
fetch(Object key)
This method is used to get the value from the cache that is mapped to the specified key. |
protected boolean |
removeEldestEntry(Map.Entry<Object,T> entry)
This is used to remove the eldest entry from the cache. |
T |
take(Object key)
This is used to exclusively take the value mapped to the specified key from the cache. |
Methods inherited from class java.util.LinkedHashMap |
---|
clear, containsValue, get |
Methods inherited from class java.util.HashMap |
---|
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.simpleframework.xml.util.Cache |
---|
isEmpty |
Methods inherited from interface java.util.Map |
---|
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
---|
public LimitedCache()
LimitedCache
object. This is
used to create a cache with a fixed size. The strategy for
this cache is least recently used. Any insert or fetch from
the cache is considered to be a use.
public LimitedCache(int capacity)
LimitedCache
object. This is
used to create a cache with a fixed size. The strategy for
this cache is least recently used. Any insert or fetch from
the cache is considered to be a use.
capacity
- this is the capacity of the cache objectMethod Detail |
---|
public void cache(Object key, T value)
cache
in interface Cache<T>
key
- this is the key to cache the provided value tovalue
- this is the value that is to be cachedpublic T take(Object key)
take
in interface Cache<T>
key
- this is the key to acquire the cache value with
public T fetch(Object key)
fetch
in interface Cache<T>
key
- this is the key to acquire the cache value with
public boolean contains(Object key)
contains
in interface Cache<T>
key
- this is the key to check within this segment
protected boolean removeEldestEntry(Map.Entry<Object,T> entry)
removeEldestEntry
in class LinkedHashMap<Object,T>
entry
- this is the eldest entry that can be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |