Interface WeakHashLRU<K>

All Known Implementing Classes:
WeakHashLRUImpl

public interface WeakHashLRU<K>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(K key)
    Adds the given key to the LRU.
    void
    Removes all entries from this LRU
    void
    Causes stale references to be cleared from the data structures.
    boolean
    contains(K key)
    Tells if the given key is in the LRU
    void
    Releases all keys that match the filter
    Removes the key that was Least Recently Used
    boolean
    remove(K key)
    Removes the given key from the LRU, if found
    int
    Returns the number of elements currently in the clock.
  • Method Details

    • add

      void add(K key)
      Adds the given key to the LRU. It will be placed at the MRU of the LRU. If this key already exists in the LRU it will be moved to the MRU
      Parameters:
      key - Must not be null
    • contains

      boolean contains(K key)
      Tells if the given key is in the LRU
      Parameters:
      key - The key to search for, may not be null
      Returns:
      true if found, false otherwise
    • remove

      boolean remove(K key)
      Removes the given key from the LRU, if found
      Parameters:
      key - The key to remove, may not be null
      Returns:
      true if removed, false otherwise
    • releaseMatching

      void releaseMatching(CacheKeyFilter<K> filter)
      Releases all keys that match the filter
      Parameters:
      filter - A non-null filter that can be used to delete every key that matches the filter
    • size

      int size()
      Returns the number of elements currently in the clock. References that have gone away because they were weakly referenced will not be counted in the size
      Returns:
      The number of entries currently in the LRU
    • remove

      K remove()
      Removes the key that was Least Recently Used
      Returns:
      The key that was removed, or null if the list is empty
    • clear

      void clear()
      Removes all entries from this LRU
    • clearStaleReferences

      void clearStaleReferences()
      Causes stale references to be cleared from the data structures. Since this is a weak clock the references can go away at any time, which happens whenever any operation has been performed. However, it may be the case that no operation will be performed for a while and so this method is provided to have a no-op operation to call in order to clear out any stale references