net.sf.swan.util
Class LRUCache

java.lang.Object
  |
  +--net.sf.swan.util.LRUCache
All Implemented Interfaces:
Cache

public class LRUCache
extends java.lang.Object
implements Cache

A cache that uses a Least Recently Used algorithm for expiring resources from the cache. When the configured capacity is exceeded, the cache makes the least recently used items available for garbage collection. Those items are removed from the cache as they are garbage collected.


Inner Class Summary
protected  class LRUCache.CacheEntry
           
protected  class LRUCache.CacheReference
           
 
Constructor Summary
LRUCache()
           
 
Method Summary
protected  void checkSize()
           
 void clear()
           
 java.lang.Object get(java.lang.Object key)
           
 int getCapacity()
           
protected  void processQueue()
           
 void put(java.lang.Object key, java.lang.Object resource)
           
 void remove(java.lang.Object key)
           
 void setCapacity(int capacity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCache

public LRUCache()
Method Detail

getCapacity

public int getCapacity()
Specified by:
getCapacity in interface Cache

setCapacity

public void setCapacity(int capacity)
Specified by:
setCapacity in interface Cache

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface Cache

put

public void put(java.lang.Object key,
                java.lang.Object resource)
Specified by:
put in interface Cache

remove

public void remove(java.lang.Object key)
Specified by:
remove in interface Cache

clear

public void clear()
Specified by:
clear in interface Cache

processQueue

protected void processQueue()

checkSize

protected void checkSize()