Class CacheEntry<T>

java.lang.Object
de.intarsys.tools.cache.CacheEntry<T>
All Implemented Interfaces:
Comparable

public class CacheEntry<T> extends Object implements Comparable
An entry in the cache implementation.

A cache entries "importance" is expressed by a "sample". The CacheEntry with the smallest sample is considered the least valuable.

This implementation supports a simple "most recently used" strategy.

  • Constructor Details

    • CacheEntry

      protected CacheEntry(Object key, T value)
      Create a cache entry.
      Parameters:
      key - The key for the entry
      value - The value for the entry
  • Method Details

    • compareTo

      public int compareTo(Object o)
      Specified by:
      compareTo in interface Comparable<T>
    • getKey

      public Object getKey()
      The key of the cache entry.
      Returns:
      Returns the key.
    • getSample

      public int getSample()
      The sample representing the "importance" of the entry.
      Returns:
      Returns the sample.
    • getValue

      public T getValue()
      The value of the cache entry.
      Returns:
      Returns the value.
    • touch

      protected void touch()
      Mark the Cache entry as recently used.