de.intarsys.tools.cache
Class CacheEntry<T>

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

public class CacheEntry<T>
extends java.lang.Object
implements java.lang.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 Summary
protected CacheEntry(java.lang.Object key, T value)
          Create a cache entry.
 
Method Summary
 int compareTo(java.lang.Object o)
           
 java.lang.Object getKey()
          The key of the cache entry.
 int getSample()
          The sample representing the "importance" of the entry.
 T getValue()
          The value of the cache entry.
protected  void touch()
          Mark the Cache entry as recently used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheEntry

protected CacheEntry(java.lang.Object key,
                     T value)
Create a cache entry.

Parameters:
key - The key for the entry
value - The value for the entry
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

getKey

public java.lang.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.