Class AutoCalculatingLRUCache<K,​V>

  • Type Parameters:
    K - the type parameter
    V - the type parameter
    All Implemented Interfaces:
    Cache<K,​V>

    public class AutoCalculatingLRUCache<K,​V>
    extends LRUCache<K,​V>
    Auto calculating LRU cache that calculates values for keys when retrieved using a SerializableFunction.
    Author:
    David B. Bracewell
    • Constructor Detail

      • AutoCalculatingLRUCache

        public AutoCalculatingLRUCache​(int maxSize,
                                       SerializableFunction<K,​V> valueCalculator)
        Instantiates a new Auto calculating lru cache.
        Parameters:
        maxSize - the max size
        valueCalculator - the value calculator
    • Method Detail

      • get

        public V get​(K key)
        Description copied from interface: Cache
        Gets the value associated with a key
        Specified by:
        get in interface Cache<K,​V>
        Overrides:
        get in class LRUCache<K,​V>
        Parameters:
        key - The key
        Returns:
        The value associated with the key or null