|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.cache.ConcurrentWeakReferenceCache<K,V>
K - V - public class ConcurrentWeakReferenceCache<K,V>
A ConcurrentWeakReferenceCache holds a given number of separated SynchronizedWeakReferenceCache instances,
called segments.
Based on the number of segments the retrieval operation will block less long for a multithreaded call to get(Object),
containsKey(Object), containsValue(Object), size() and isEmpty(), but any additional
segment will increase the blocking time for any put(Object, Object), putAll(Map), remove(Object) and
clear() call, as well as it is increasing the memory footprint since every segment will hold all the information
within the Cache.
Cache,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
ConcurrentWeakReferenceCache()
This does create a ConcurrentWeakReferenceCache which uses as many segments as the
Runtime.availableProcessors() returns |
|
ConcurrentWeakReferenceCache(int numberOfSegments)
|
|
| Method Summary | |
|---|---|
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set<Map.Entry<K,V>> |
entrySet()
Returns an unmodifiable Set of all Map.Entrys within the Cache which only represents a
snapshot in moment |
boolean |
equals(Object o)
|
V |
get(Object key)
|
V |
getOrCreate(K key,
Factory<V> factory)
Gets a cached value or creates a new one using the given Factory and puts the new value into the cache. |
int |
hashCode()
|
boolean |
isEmpty()
|
Set<K> |
keySet()
Returns an unmodifiable Set of all keys within the Cache which only represents a snapshot in moment |
V |
put(K key,
V value)
|
void |
putAll(Map<? extends K,? extends V> m)
|
V |
remove(Object key)
|
int |
size()
|
Collection<V> |
values()
Returns an unmodifiable Collection of all values within the Cache which only represents a snapshot in moment |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConcurrentWeakReferenceCache()
ConcurrentWeakReferenceCache which uses as many segments as the
Runtime.availableProcessors() returns
ConcurrentWeakReferenceCachepublic ConcurrentWeakReferenceCache(int numberOfSegments)
numberOfSegments - ConcurrentWeakReferenceCache| Method Detail |
|---|
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
public boolean containsValue(Object value)
public V get(Object key)
public V put(K key,
V value)
public V remove(Object key)
public void putAll(Map<? extends K,? extends V> m)
public void clear()
public Set<K> keySet()
CacheSet of all keys within the Cache which only represents a snapshot in moment
public Collection<V> values()
CacheCollection of all values within the Cache which only represents a snapshot in moment
public Set<Map.Entry<K,V>> entrySet()
CacheSet of all Map.Entrys within the Cache which only represents a
snapshot in moment
public boolean equals(Object o)
equals in interface Map<K,V>equals in class Objectpublic int hashCode()
hashCode in interface Map<K,V>hashCode in class Object
public V getOrCreate(K key,
Factory<V> factory)
CacheFactory and puts the new value into the cache.
getOrCreate in interface Cache<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||