net.sf.farrago.util
Class FarragoLruVictimPolicy

java.lang.Object
  extended by net.sf.farrago.util.FarragoLruVictimPolicy
All Implemented Interfaces:
FarragoCacheVictimPolicy

public class FarragoLruVictimPolicy
extends Object
implements FarragoCacheVictimPolicy

FarragoLruVictimPolicy implements an LRU caching policy for the FarragoObjectCache.

This class assumes that synchronization is handled by its caller.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/util/FarragoLruVictimPolicy.java#6 $
Author:
Zelaine Fong

Field Summary
private  LinkedHashSet<FarragoCacheEntry> lruCacheOrder
          LRU ordering of objects in the cache.
 
Constructor Summary
FarragoLruVictimPolicy()
           
 
Method Summary
 void accessEntry(FarragoCacheEntry entry)
          Receives notification that an existing entry in the cache is being accessed.
 void clearCache()
          Receives notification that all entries are being removed from the cache
 Iterator<FarragoCacheEntry> getVictimIterator()
          Returns an iterator corresponding to a list of potential entries for removal from the cache, in the order of precedence.
 FarragoCacheEntry newEntry(FarragoObjectCache parentCache)
          Creates a new cache entry
 void registerEntry(FarragoCacheEntry entry)
          Receives notification that a new entry is being added to the cache.
 void unregisterEntry(FarragoCacheEntry entry)
          Receives notification that an entry is being removed from the cache.
 void unregisterEntry(Iterator victimRange)
          Unregisters the current entry being accessed from the victim range
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lruCacheOrder

private final LinkedHashSet<FarragoCacheEntry> lruCacheOrder
LRU ordering of objects in the cache. The linked list provides the LRU ordering.

Constructor Detail

FarragoLruVictimPolicy

public FarragoLruVictimPolicy()
Method Detail

newEntry

public FarragoCacheEntry newEntry(FarragoObjectCache parentCache)
Description copied from interface: FarragoCacheVictimPolicy
Creates a new cache entry

Specified by:
newEntry in interface FarragoCacheVictimPolicy
Parameters:
parentCache - the cache this entry is associated with

registerEntry

public void registerEntry(FarragoCacheEntry entry)
Description copied from interface: FarragoCacheVictimPolicy
Receives notification that a new entry is being added to the cache.

Specified by:
registerEntry in interface FarragoCacheVictimPolicy
Parameters:
entry - new entry being added to the cache

unregisterEntry

public void unregisterEntry(Iterator victimRange)
Description copied from interface: FarragoCacheVictimPolicy
Unregisters the current entry being accessed from the victim range

Specified by:
unregisterEntry in interface FarragoCacheVictimPolicy
Parameters:
victimRange - iterator corresponding to the victim range

unregisterEntry

public void unregisterEntry(FarragoCacheEntry entry)
Description copied from interface: FarragoCacheVictimPolicy
Receives notification that an entry is being removed from the cache.

Specified by:
unregisterEntry in interface FarragoCacheVictimPolicy
Parameters:
entry - entry to be removed

accessEntry

public void accessEntry(FarragoCacheEntry entry)
Description copied from interface: FarragoCacheVictimPolicy
Receives notification that an existing entry in the cache is being accessed.

Specified by:
accessEntry in interface FarragoCacheVictimPolicy
Parameters:
entry - entry being accessed

getVictimIterator

public Iterator<FarragoCacheEntry> getVictimIterator()
Description copied from interface: FarragoCacheVictimPolicy
Returns an iterator corresponding to a list of potential entries for removal from the cache, in the order of precedence.

Specified by:
getVictimIterator in interface FarragoCacheVictimPolicy
Returns:
iterator corresponding to cache victims

clearCache

public void clearCache()
Description copied from interface: FarragoCacheVictimPolicy
Receives notification that all entries are being removed from the cache

Specified by:
clearCache in interface FarragoCacheVictimPolicy