org.apache.commons.cache
Class LRUEvictionPolicy

java.lang.Object
  extended by org.apache.commons.cache.LRUEvictionPolicy
All Implemented Interfaces:
Serializable, Iterator, CachedObjectIterator, EvictionPolicy, RetrievalListener, StorageListener

public class LRUEvictionPolicy
extends Object
implements EvictionPolicy, StorageListener, RetrievalListener, CachedObjectIterator

tk.

Version:
$Id: LRUEvictionPolicy.java 155435 2005-02-26 13:17:27Z dirkv $
Author:
Rodney Waldhoff
See Also:
Serialized Form

Field Summary
 Cache _cache
           
protected  boolean _canRemove
           
protected  WListableObject _current
           
protected  HashMap _hash
           
protected  WListableObject _leastRecent
           
protected  WListableObject _mostRecent
           
protected  int _objsbetweennaps
           
protected  long _sleeptimemillis
           
 
Constructor Summary
LRUEvictionPolicy()
           
LRUEvictionPolicy(int objsbetweennaps, long sleeptimemillis)
           
 
Method Summary
protected  void addToList(WListableObject cur)
           
 void cleared()
           
 void cleared(Serializable key)
           
 Serializable getEvictionCandidate()
           
 Serializable[] getEvictionCandidates(int n)
           
 CachedObjectInfo getNext()
           
 boolean hasNext()
           
 Object next()
           
 void notRetrieved(Serializable key)
           
 void notStored(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group)
           
 void remove()
           
protected  void removeFromList(WListableObject cur)
           
 void retrieved(Serializable key)
           
 void retrieveRequested(Serializable key)
           
 void setCache(Cache c)
          Sets my cache.
 void stored(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group)
           
 void storeRequested(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group)
           
 String toString()
           
 void unsetCache()
          Unsets my cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_hash

protected transient HashMap _hash

_leastRecent

protected transient WListableObject _leastRecent

_mostRecent

protected transient WListableObject _mostRecent

_current

protected transient WListableObject _current

_canRemove

protected boolean _canRemove

_cache

public Cache _cache

_objsbetweennaps

protected int _objsbetweennaps

_sleeptimemillis

protected long _sleeptimemillis
Constructor Detail

LRUEvictionPolicy

public LRUEvictionPolicy()

LRUEvictionPolicy

public LRUEvictionPolicy(int objsbetweennaps,
                         long sleeptimemillis)
Method Detail

addToList

protected void addToList(WListableObject cur)

removeFromList

protected void removeFromList(WListableObject cur)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator
Specified by:
hasNext in interface CachedObjectIterator

getNext

public CachedObjectInfo getNext()
                         throws NoSuchElementException
Specified by:
getNext in interface CachedObjectIterator
Throws:
NoSuchElementException

next

public Object next()
            throws NoSuchElementException
Specified by:
next in interface Iterator
Specified by:
next in interface CachedObjectIterator
Throws:
NoSuchElementException

remove

public void remove()
            throws NoSuchElementException,
                   IllegalStateException
Specified by:
remove in interface Iterator
Specified by:
remove in interface CachedObjectIterator
Throws:
NoSuchElementException
IllegalStateException

setCache

public void setCache(Cache c)
Sets my cache.

Specified by:
setCache in interface EvictionPolicy

unsetCache

public void unsetCache()
Unsets my cache.

Specified by:
unsetCache in interface EvictionPolicy

storeRequested

public void storeRequested(Serializable key,
                           Serializable val,
                           Long expiresAt,
                           Long cost,
                           Serializable group)
Specified by:
storeRequested in interface StorageListener

notStored

public void notStored(Serializable key,
                      Serializable val,
                      Long expiresAt,
                      Long cost,
                      Serializable group)
Specified by:
notStored in interface StorageListener

stored

public void stored(Serializable key,
                   Serializable val,
                   Long expiresAt,
                   Long cost,
                   Serializable group)
Specified by:
stored in interface StorageListener

cleared

public void cleared(Serializable key)
Specified by:
cleared in interface StorageListener

cleared

public void cleared()
Specified by:
cleared in interface StorageListener

retrieveRequested

public void retrieveRequested(Serializable key)
Specified by:
retrieveRequested in interface RetrievalListener

retrieved

public void retrieved(Serializable key)
Specified by:
retrieved in interface RetrievalListener

notRetrieved

public void notRetrieved(Serializable key)
Specified by:
notRetrieved in interface RetrievalListener

getEvictionCandidate

public Serializable getEvictionCandidate()
Specified by:
getEvictionCandidate in interface EvictionPolicy

getEvictionCandidates

public Serializable[] getEvictionCandidates(int n)
Specified by:
getEvictionCandidates in interface EvictionPolicy

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.