|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simpleframework.xml.util.WeakCache<T>
public class WeakCache<T>
The WeakCache
object is an implementation of a cache
that holds on to cached items only if the key remains in memory.
This is effectively like a concurrent hash map with weak keys, it
ensures that multiple threads can concurrently access weak hash
maps in a way that lowers contention for the locks used.
Constructor Summary | |
---|---|
WeakCache()
Constructor for the WeakCache object. |
|
WeakCache(int size)
Constructor for the WeakCache object. |
Method Summary | |
---|---|
void |
cache(java.lang.Object key,
T value)
This method is used to insert a key value mapping in to the cache. |
boolean |
contains(java.lang.Object key)
This is used to determine whether the specified key exists with in the cache. |
T |
fetch(java.lang.Object key)
This method is used to get the value from the cache that is mapped to the specified key. |
boolean |
isEmpty()
This method is used to determine if the cache is empty. |
T |
take(java.lang.Object key)
This is used to exclusively take the value mapped to the specified key from the cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WeakCache()
WeakCache
object. This is
used to create a cache that stores values in such a way that
when the key is garbage collected the value is removed from
the map. This is similar to the concurrent hash map.
public WeakCache(int size)
WeakCache
object. This is
used to create a cache that stores values in such a way that
when the key is garbage collected the value is removed from
the map. This is similar to the concurrent hash map.
size
- this is the number of segments within the cacheMethod Detail |
---|
public boolean isEmpty()
Cache
isEmpty
in interface Cache<T>
public void cache(java.lang.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(java.lang.Object key)
take
in interface Cache<T>
key
- this is the key to acquire the cache value with
public T fetch(java.lang.Object key)
fetch
in interface Cache<T>
key
- this is the key to acquire the cache value with
public boolean contains(java.lang.Object key)
contains
in interface Cache<T>
key
- this is the key to check within this segment
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |