org.jmage.cache
Class LRUMemoryCache

java.lang.Object
  extended by org.jmage.cache.LRUMemoryCache
All Implemented Interfaces:
Cache

public class LRUMemoryCache
extends java.lang.Object
implements Cache

LRU Cache dismisses the least recently used object in the cache upon adding new ones, once the cache's capacity has been met.


Field Summary
protected  int capacity
           
protected static org.apache.log4j.Logger log
           
protected  java.util.LinkedHashMap pages
           
 
Constructor Summary
LRUMemoryCache()
           
 
Method Summary
 void destroy()
          Destroy the cache
protected  int getCapacity()
           
protected  int getSize()
           
 void init(java.util.Properties properties)
          Initialize the cache using Properties
 void pageIn(java.lang.Object key, java.lang.Object object)
          Pages an object into the cache, affecting it's cache ranking.
 java.lang.Object pageOut(java.lang.Object key)
          Pages an object out of the cache, affecting it's cache ranking.
 void remove(java.lang.Object object)
          Removes an object from the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pages

protected java.util.LinkedHashMap pages

capacity

protected int capacity

log

protected static org.apache.log4j.Logger log
Constructor Detail

LRUMemoryCache

public LRUMemoryCache()
Method Detail

init

public void init(java.util.Properties properties)
          throws CacheException
Description copied from interface: Cache
Initialize the cache using Properties

Specified by:
init in interface Cache
Throws:
CacheException

pageIn

public void pageIn(java.lang.Object key,
                   java.lang.Object object)
            throws CacheException
Description copied from interface: Cache
Pages an object into the cache, affecting it's cache ranking.

Specified by:
pageIn in interface Cache
Parameters:
key - the key
object - the object
Throws:
CacheException

pageOut

public java.lang.Object pageOut(java.lang.Object key)
                         throws CacheException
Description copied from interface: Cache
Pages an object out of the cache, affecting it's cache ranking.

Specified by:
pageOut in interface Cache
Parameters:
key - the object's cache key
Returns:
the object
Throws:
CacheException

remove

public void remove(java.lang.Object object)
Description copied from interface: Cache
Removes an object from the cache

Specified by:
remove in interface Cache
Parameters:
object - the object's cache key

destroy

public void destroy()
             throws CacheException
Description copied from interface: Cache
Destroy the cache

Specified by:
destroy in interface Cache
Throws:
CacheException

getCapacity

protected int getCapacity()

getSize

protected int getSize()


Copyright © 2004-2008 Sourceforge. All Rights Reserved.