Class ExpiringConcurrentCache<K,​V>


  • public final class ExpiringConcurrentCache<K,​V>
    extends ConcurrentCache<K,​V>
    This class implements an abstract ConcurrentCache with objects in the cache potentially expiring. Only non-expired objects will be returned from the cache or considered to be contained in the cache The cache is self-managing, so no remove() method is defined
    • Constructor Detail

      • ExpiringConcurrentCache

        public ExpiringConcurrentCache​(ConcurrentCache.Factory<K,​V> f,
                                       ExpiringConcurrentCache.ExpiryChecker<K,​V> checker)
        Public constructor.
        Parameters:
        f - used to create new instances of objects that are not already available
        checker - used to check whether an object in the cache has expired
    • Method Detail

      • get

        public V get​(K key)
              throws ExecutionException
        Description copied from class: ConcurrentCache
        Retrieves a value for the specified key. If the value is not already present in the cache, a new instance will be allocated using the Factory interface
        Specified by:
        get in class ConcurrentCache<K,​V>
        Parameters:
        key - the key the value is associated with
        Returns:
        the value for the specified key
        Throws:
        ExecutionException
      • containsKey

        public boolean containsKey​(K key)
        Description copied from class: ConcurrentCache
        Tests whether the cache contains a value for the specified key
        Specified by:
        containsKey in class ConcurrentCache<K,​V>
        Parameters:
        key - key to test
        Returns:
        true if the value for the specified key is already cached, false otherwise