efficom.runningjoe.services
Class LRUCache<K,V>

java.lang.Object
  extended by efficom.runningjoe.services.LRUCache<K,V>

public class LRUCache<K,V>
extends java.lang.Object

A simple implementation of an LRU cache.

Retrieved from Stackoverflow.


Nested Class Summary
static interface LRUCache.CacheEntryRemovedListener<K,V>
          Called when a cached element is about to be removed.
 
Constructor Summary
LRUCache(int maxEntries)
          Creates the cache with the specified max entries.
 
Method Summary
 void add(K key, V value)
           
 V get(K key)
           
 java.util.Collection<V> retrieveAll()
           
 void setEntryRemovedListener(LRUCache.CacheEntryRemovedListener<K,V> entryRemovedListener)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCache

public LRUCache(int maxEntries)
Creates the cache with the specified max entries.

Method Detail

add

public void add(K key,
                V value)

get

public V get(K key)

retrieveAll

public java.util.Collection<V> retrieveAll()

setEntryRemovedListener

public void setEntryRemovedListener(LRUCache.CacheEntryRemovedListener<K,V> entryRemovedListener)