K
- key typeV
- value typepublic final class ConcurrentCache<K,V> extends Object
Base synchronized cache for *Registry objects.
Do not use this class directly.
This class is thread-safe.
Constructor and Description |
---|
ConcurrentCache()
Create a new synchronized cache.
|
ConcurrentCache(int maxElements)
Create a new synchronized cache specifying a maximum size for the cache
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the cache.
|
V |
computeAndGet(K key,
V value)
Puts a value into the cache and returns it.
|
V |
get(K key)
Get the value for a specific key
|
public ConcurrentCache()
Create a new synchronized cache.
public ConcurrentCache(int maxElements)
Create a new synchronized cache specifying a maximum size for the cache
maxElements
- the maximum number of elements this cache can containpublic void clear()
Clear the cache.
public V get(K key)
Get the value for a specific key
key
- the keypublic V computeAndGet(K key, V value)
Puts a value into the cache and returns it. If a value already existed for the same key, the existing value is not modified and is returned instead of the one passed as parameter. This ensures only one object for each key exists at a time.
key
- the key to which the value will be assignedvalue
- the value which will be added to the mapCopyright © 2016 The JAVARUNTYPE team. All Rights Reserved.