Class WeakMonitorCache<K,​V extends Comparable<V>>

    • 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.