org.globus.wsrf.utils.cache
Class LRUCache

java.lang.Object
  extended byorg.globus.wsrf.utils.cache.LRUCache
All Implemented Interfaces:
Cache, Initializable, commonj.timers.TimerListener

public class LRUCache
extends java.lang.Object
implements Initializable, commonj.timers.TimerListener, Cache

LRU cache implementation. The most recently used move to the end of the list while the least recently used stay at the beginning of the list. The least recently used (within a timeout period) are removed periodically.


Nested Class Summary
private static class LRUCache.Entry
           
 
Field Summary
private  java.util.Map cache
           
private static int DEFAULT_DELAY
           
private static int DEFAULT_TIMEOUT
           
private  long delay
           
private  boolean initialized
           
private  LinkedNodeList list
           
private static org.apache.commons.logging.Log logger
           
private  long timeout
           
private  commonj.timers.Timer timer
           
private  commonj.timers.TimerManager timerManager
           
 
Constructor Summary
LRUCache()
           
 
Method Summary
 void cleanExpired()
           
 void clear()
           
 long getDelay()
           
 int getSize()
           
 long getTimeout()
           
 void initialize()
           
 void remove(java.lang.Object resource)
           
private  void resetTimer()
           
private  void scheduleTimer()
           
 void setDelay(long delay)
           
 void setTimeout(long timeout)
           
 void timerExpired(commonj.timers.Timer timer)
           
 void update(java.lang.Object resource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

private static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

DEFAULT_DELAY

private static final int DEFAULT_DELAY
See Also:
Constant Field Values

logger

private static org.apache.commons.logging.Log logger

cache

private java.util.Map cache

list

private LinkedNodeList list

timerManager

private commonj.timers.TimerManager timerManager

timer

private commonj.timers.Timer timer

timeout

private long timeout

delay

private long delay

initialized

private boolean initialized
Constructor Detail

LRUCache

public LRUCache()
Method Detail

setTimeout

public void setTimeout(long timeout)

getTimeout

public long getTimeout()

setDelay

public void setDelay(long delay)

getDelay

public long getDelay()

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface Initializable
Throws:
java.lang.Exception

resetTimer

private void resetTimer()

scheduleTimer

private void scheduleTimer()

update

public void update(java.lang.Object resource)
Specified by:
update in interface Cache

remove

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

clear

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

getSize

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

cleanExpired

public void cleanExpired()

timerExpired

public void timerExpired(commonj.timers.Timer timer)
Specified by:
timerExpired in interface commonj.timers.TimerListener