TUM CCSM Commons

edu.tum.cs.commons.cache
Class LRUCacheBase<I,H,E,X extends java.lang.Exception>

java.lang.Object
  extended by edu.tum.cs.commons.cache.CacheBase<I,H,E,X>
      extended by edu.tum.cs.commons.cache.LRUCacheBase<I,H,E,X>
Type Parameters:
I - the index type of the cache
H - the hash map key type
E - the type stored in the cache
X - the type of exception thrown by the CacheBase.obtainItem(Object) method. Use the NeverThrownRuntimeException if no exception will be thrown.
Direct Known Subclasses:
LRUStraightCacheBase

public abstract class LRUCacheBase<I,H,E,X extends java.lang.Exception>
extends CacheBase<I,H,E,X>

A cache with a fixed size using a last recently used (LRU) strategy. If identifiers itself are suitable hash keys, use class LRUStraightCacheBase.

Version:
$Rev: 26268 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: 7C20602D714E70624D8FF1B0F6BAAEFF

Constructor Summary
LRUCacheBase(int maxSize)
          Constructor.
 
Method Summary
 E getItem(I identifier)
          Obtain an item from the cache.
 
Methods inherited from class edu.tum.cs.commons.cache.CacheBase
getHashKey, obtainItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCacheBase

public LRUCacheBase(int maxSize)
Constructor.

Method Detail

getItem

public E getItem(I identifier)
          throws X extends java.lang.Exception
Obtain an item from the cache. If the item was not cached yet, it will be cached.

Specified by:
getItem in class CacheBase<I,H,E,X extends java.lang.Exception>
Parameters:
identifier - an object identifying the item to retrieve from the cache. This class' implementation works with a hash map so identifiers must adhere to the conventions for Object.hashcode().
Returns:
The item.
Throws:
X extends java.lang.Exception

TUM CCSM Commons

TUM CCSM Commons - 2.7