Package org.simpleframework.xml.util
Class ConcurrentCache<T>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentHashMap<java.lang.Object,T>
-
- org.simpleframework.xml.util.ConcurrentCache<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.concurrent.ConcurrentMap<java.lang.Object,T>
,java.util.Map<java.lang.Object,T>
,Cache<T>
- Direct Known Subclasses:
ScannerBuilder
,ScannerBuilder.Entry
public class ConcurrentCache<T> extends java.util.concurrent.ConcurrentHashMap<java.lang.Object,T> implements Cache<T>
TheConcurrentCache
interface is used to represent a cache that will store key value pairs. This implementation is backed by aConcurrentHashMap
for best performance.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
java.util.concurrent.ConcurrentHashMap.KeySetView<K extends java.lang.Object,V extends java.lang.Object>
-
-
Constructor Summary
Constructors Constructor Description ConcurrentCache()
Constructor for theConcurrentCache
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.util.concurrent.ConcurrentHashMap
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
-
-
-
-
Method Detail
-
cache
public void cache(java.lang.Object key, T value)
This method is used to insert a key value mapping in to the cache. The value can later be retrieved or removed from the cache if desired. If the value associated with the key is null then nothing is stored within the cache.
-
take
public T take(java.lang.Object key)
This is used to exclusively take the value mapped to the specified key from the cache. Invoking this is effectively removing the value from the cache.
-
fetch
public T fetch(java.lang.Object key)
This method is used to get the value from the cache that is mapped to the specified key. If there is no value mapped to the specified key then this method will return a null.
-
contains
public boolean contains(java.lang.Object key)
This is used to determine whether the specified key exists with in the cache. Typically this can be done using the fetch method, which will acquire the object.
-
-