Class StagedLruCache<K,​V>

  • All Implemented Interfaces:
    Cache<K,​V>

    public final class StagedLruCache<K,​V>
    extends Object
    implements Cache<K,​V>
    • Field Detail

      • DEFAULT_OLD_GEN_RATIO

        public static final double DEFAULT_OLD_GEN_RATIO
        The default capacity of an object cache relative to its capacity.
        See Also:
        Constant Field Values
      • DEFAULT_OLD_GEN_AFTER_HITS

        public static final int DEFAULT_OLD_GEN_AFTER_HITS
        The number of hits after which an entry is put into the old-generation lru
        See Also:
        Constant Field Values
    • Constructor Detail

      • StagedLruCache

        public StagedLruCache()
      • StagedLruCache

        public StagedLruCache​(int capacity)
      • StagedLruCache

        public StagedLruCache​(Cloner<V> valueCloner)
      • StagedLruCache

        public StagedLruCache​(int capacity,
                              Cloner<V> valueCloner,
                              double oldGenRatio,
                              int oldGenAfterHits)
    • Method Detail

      • set

        public void set​(K key,
                        V value)
        Description copied from interface: Cache
        Sets a key-value-pair to the cache.
        Specified by:
        set in interface Cache<K,​V>
      • get

        public V get​(K key)
        Description copied from interface: Cache
        Query a value from the cache by its key.
        Specified by:
        get in interface Cache<K,​V>
        Returns:
        null if no value for the given key was found. Otherwise the value for this key.
      • remove

        public void remove​(K key)
        Description copied from interface: Cache
        Remove a key-value-pair from the cache.
        Specified by:
        remove in interface Cache<K,​V>
      • capacity

        public int capacity()
        Specified by:
        capacity in interface Cache<K,​V>
        Returns:
        the capacity of this cache.
      • clear

        public void clear()
        Description copied from interface: Cache
        Remove all elements from the cache.
        Specified by:
        clear in interface Cache<K,​V>