Class WeakMonitorCache<K,V extends Comparable<V>>
- java.lang.Object
-
- org.symphonyoss.s2.canon.runtime.cache.WeakCache<K,IMonitor<V>>
-
- org.symphonyoss.s2.canon.runtime.cache.WeakMonitorCache<K,V>
-
public class WeakMonitorCache<K,V extends Comparable<V>> extends WeakCache<K,IMonitor<V>>
-
-
Constructor Summary
Constructors Constructor Description WeakMonitorCache(SynchronousProducer<IMonitor<V>> producer, IMonitorFactory<K,V> monitorFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMonitor<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.-
Methods inherited from class org.symphonyoss.s2.canon.runtime.cache.WeakCache
cache, fetch, getAllCached, put
-
-
-
-
Constructor Detail
-
WeakMonitorCache
public WeakMonitorCache(SynchronousProducer<IMonitor<V>> producer, IMonitorFactory<K,V> monitorFactory)
-
-
Method Detail
-
cache
public IMonitor<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 true then notify all listeners using the given trace context.- Returns:
- The "one true instance" of that object.
-
-