Module tvbrowser
Package util.misc

Class SoftReferenceCache<T,​K>


  • public class SoftReferenceCache<T,​K>
    extends java.lang.Object
    This class implements a Cache using soft references. As soon as the garbage collector tries to remove an object, it gets removed from the cache.
    Since:
    2.7
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanUp()
      Cleanup the cache.
      void clear()
      Clear the cache
      boolean containsKey​(T key)
      Checks if the cache contains a specific key
      K get​(T key)
      Get the value from the Cache
      void put​(T key, K object)
      Put a object into the cache
      void remove​(T key)
      Remove item from cache
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SoftReferenceCache

        public SoftReferenceCache()
    • Method Detail

      • get

        public K get​(T key)
        Get the value from the Cache
        Parameters:
        key - get value for this key
        Returns:
        The referenced Object.
      • put

        public void put​(T key,
                        K object)
        Put a object into the cache
        Parameters:
        key - key for this object
        object - object to store in the cache
      • remove

        public void remove​(T key)
        Remove item from cache
        Parameters:
        key - remove item that references this key
      • clear

        public void clear()
        Clear the cache
      • cleanUp

        public void cleanUp()
        Cleanup the cache. Every garbage collected item must be removed
      • containsKey

        public boolean containsKey​(T key)
        Checks if the cache contains a specific key
        Parameters:
        key - search for this key
        Returns:
        true if this cache contains this key