Class WeakCache<K,V>
- java.lang.Object
-
- org.symphonyoss.s2.canon.runtime.cache.WeakCache<K,V>
-
- Direct Known Subclasses:
WeakMonitorCache
public class WeakCache<K,V> extends Object
-
-
Constructor Summary
Constructors Constructor Description WeakCache()WeakCache(IProducerImpl<V> producer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vcache(K key, V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)Cache the given object as the current version unless it is in the cache already, in which case return the existing value.Vfetch(K k)Collection<V>getAllCached()protected voidput(K key, V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
-
-
-
Constructor Detail
-
WeakCache
public WeakCache()
-
WeakCache
public WeakCache(IProducerImpl<V> producer)
-
-
Method Detail
-
getAllCached
public Collection<V> getAllCached()
-
cache
public V cache(K key, V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
Cache the given object as the current version unless it is in the cache already, in which case return the existing value. In order to minimize synchronization when we load an object from persistent storage we look in the cache, if it is not there we load it from storage and then call this method. If 2 threads try to load the same object at the same time they will both deserialize the object but one of them gets discarded as after loading both threads call this method.- Parameters:
key- The key.value- The object.trace- If non-null then notify all listeners using the given trace context.- Returns:
- The "one true instance" of that object.
-
-