Class Cache<K,​V>


  • public class Cache<K,​V>
    extends Object
    A concurrent caching mechanism.
    • Constructor Detail

      • Cache

        public Cache​(Cache.Factory<K,​V> factory)
        Constructs this cache using the specified Factory.
        Parameters:
        factory -
    • Method Detail

      • get

        public V get​(K key)
        If a value isn't associated with the specified key, a new Callable will be created wrapping the Factory specified via the constructor and passed to a FutureTask. This task will be passed to the backing ConcurrentMap. When FutureTask.get() is invoked, the Factory will return the new Value which will be cached by the FutureTask.
        Parameters:
        key - the key the value is associated with
        Returns:
        the value for the specified key, if any
      • remove

        public V remove​(K key)