org.gjt.rec.cache
Interface Cache

All Known Implementing Classes:
FixedCache, MapCache, TagCache

public interface Cache

The interface implemented by all caches.

Author:
Neil Stockbridge

Field Summary
static String REVISION
           
 
Method Summary
 int elementCount()
           
 int hitCount()
           
 void invalidate(Object id)
          Invalidates the entry in this cache with a particular id.
 void invalidateAll()
          Invalidates all entries in this cache.
 Object lookup(Object id)
          Tries to find an element with a particular id in this cache.
 void put(Object id, Object element)
          Puts a particular element in this cache associated with a particular id.
 int requestCount()
           
 void resetStatistics()
          Resets the cache performance statistics to the values as they were when the cache was created.
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
Method Detail

lookup

public Object lookup(Object id)
Tries to find an element with a particular id in this cache.

Parameters:
id - the id of the desired element.
Returns:
the element corresponding to the supplied id or null if no such element could be found.

put

public void put(Object id,
                Object element)
Puts a particular element in this cache associated with a particular id. Note that invoking this method does not guarantee that the element will stay in the cache even long enough to be returned by a subsequent invocation of the lookup(Object) method.

Parameters:
id - the id associated with the supplied element.
element - the element to store in the cache.
Throws:
IllegalArgumentException - if the supplied element is null.

invalidate

public void invalidate(Object id)
Invalidates the entry in this cache with a particular id.

Parameters:
id - the id corresponding to the element to invalidate.

invalidateAll

public void invalidateAll()
Invalidates all entries in this cache.


elementCount

public int elementCount()
Returns:
the number of elements in this cache. this number is the actual number of elements cached, not the size of the element store.

requestCount

public int requestCount()
Returns:
the number of cache requests made of this cache.

hitCount

public int hitCount()
Returns:
the number of cache requests that have been satisfied by this cache.

resetStatistics

public void resetStatistics()
Resets the cache performance statistics to the values as they were when the cache was created.