org.apache.avalon.excalibur.cache.policy
Class TimeMapLRUPolicy

java.lang.Object
  |
  +--org.apache.avalon.excalibur.cache.policy.TimeMapLRUPolicy
All Implemented Interfaces:
ReplacementPolicy

public class TimeMapLRUPolicy
extends java.lang.Object
implements ReplacementPolicy

TimeMapLRU(Least Recently Used) replacement policy. Use a TreeMap with logical time to perform LRU selectVictim operations. On large cache this implementation should be really faster (since it uses a log(n) treemap plus an hashmap) than the current LRU implem that is working with a List.

Author:
Alexis Agahi

Field Summary
protected  java.util.HashMap m_keyToTimeMap
           
protected  java.util.TreeMap m_timeToKeyMap
           
 
Constructor Summary
TimeMapLRUPolicy()
           
 
Method Summary
 void add(java.lang.Object key)
           
 void hit(java.lang.Object key)
           
 void remove(java.lang.Object key)
           
 java.lang.Object selectVictim()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_timeToKeyMap

protected java.util.TreeMap m_timeToKeyMap

m_keyToTimeMap

protected java.util.HashMap m_keyToTimeMap
Constructor Detail

TimeMapLRUPolicy

public TimeMapLRUPolicy()
Method Detail

hit

public void hit(java.lang.Object key)
Specified by:
hit in interface ReplacementPolicy

add

public void add(java.lang.Object key)
Specified by:
add in interface ReplacementPolicy

remove

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

selectVictim

public java.lang.Object selectVictim()
Specified by:
selectVictim in interface ReplacementPolicy


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.