org.apache.jcs.engine.memory.lru
Class LHMLRUMemoryCache

java.lang.Object
  extended by org.apache.jcs.engine.memory.AbstractMemoryCache
      extended by org.apache.jcs.engine.memory.lru.LHMLRUMemoryCache
All Implemented Interfaces:
Serializable, IMemoryCache, MemoryCache

public class LHMLRUMemoryCache
extends AbstractMemoryCache

This is a test memory manager using the jdk1.4 LinkedHashMap.

See Also:
Serialized Form

Nested Class Summary
 class LHMLRUMemoryCache.LHMSpooler
          Implementation of removeEldestEntry in LinkedHashMap
 
Field Summary
protected  int hitCnt
          number of hits
protected  int missCnt
          number of misses
protected  int putCnt
          number of puts
 
Fields inherited from class org.apache.jcs.engine.memory.AbstractMemoryCache
cache, cacheAttributes, cacheName, chunkSize, elementAttributes, map, status
 
Constructor Summary
LHMLRUMemoryCache()
           
 
Method Summary
 Map createMap()
          Returns a synchronized LHMSpooler
 void dumpCacheEntries()
          Dump the cache entries from first to last for debugging.
 void dumpMap()
          Dump the cache map for debugging.
 int freeElements(int numberToFree)
          This can't be implemented.
 ICacheElement get(Serializable key)
          Get an item from the cache
 Object[] getKeyArray()
          Get an Array of the keys for all elements in the memory cache
 ICacheElement getQuiet(Serializable key)
          Get an item from the cache without affecting its last access time or position.
 IStats getStatistics()
          This returns semi-structured information on the memory cache, such as the size, put count, hit count, and miss count.
 void initialize(CompositeCache hub)
          For post reflection creation initialization
 boolean remove(Serializable key)
          Removes an item from the cache.
 void update(ICacheElement ce)
          Puts an item to the cache.
 
Methods inherited from class org.apache.jcs.engine.memory.AbstractMemoryCache
dispose, getCacheAttributes, getCacheName, getCompositeCache, getGroupKeys, getIterator, getMultiple, getSize, getStatus, removeAll, setCacheAttributes, waterfal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hitCnt

protected int hitCnt
number of hits


missCnt

protected int missCnt
number of misses


putCnt

protected int putCnt
number of puts

Constructor Detail

LHMLRUMemoryCache

public LHMLRUMemoryCache()
Method Detail

initialize

public void initialize(CompositeCache hub)
For post reflection creation initialization

Specified by:
initialize in interface IMemoryCache
Overrides:
initialize in class AbstractMemoryCache
Parameters:
hub -

createMap

public Map createMap()
Returns a synchronized LHMSpooler

Specified by:
createMap in class AbstractMemoryCache
Returns:
Collections.synchronizedMap( new LHMSpooler() )

update

public void update(ICacheElement ce)
            throws IOException
Puts an item to the cache.

Specified by:
update in interface IMemoryCache
Specified by:
update in class AbstractMemoryCache
Parameters:
ce - Description of the Parameter
Throws:
IOException

getQuiet

public ICacheElement getQuiet(Serializable key)
                       throws IOException
Get an item from the cache without affecting its last access time or position. There is no way to do this with the LinkedHashMap!

Specified by:
getQuiet in interface IMemoryCache
Overrides:
getQuiet in class AbstractMemoryCache
Parameters:
key - Identifies item to find
Returns:
Element matching key if found, or null
Throws:
IOException

get

public ICacheElement get(Serializable key)
                  throws IOException
Get an item from the cache

Specified by:
get in interface IMemoryCache
Specified by:
get in class AbstractMemoryCache
Parameters:
key - Identifies item to find
Returns:
ICacheElement if found, else null
Throws:
IOException

remove

public boolean remove(Serializable key)
               throws IOException
Removes an item from the cache. This method handles hierarchical removal. If the key is a String and ends with the CacheConstants.NAME_COMPONENT_DELIMITER, then all items with keys starting with the argument String will be removed.

Specified by:
remove in interface IMemoryCache
Specified by:
remove in class AbstractMemoryCache
Parameters:
key -
Returns:
true if removed
Throws:
IOException

getKeyArray

public Object[] getKeyArray()
Get an Array of the keys for all elements in the memory cache

Specified by:
getKeyArray in interface IMemoryCache
Specified by:
getKeyArray in class AbstractMemoryCache
Returns:
An Object[]

getStatistics

public IStats getStatistics()
This returns semi-structured information on the memory cache, such as the size, put count, hit count, and miss count.

Specified by:
getStatistics in interface IMemoryCache
Overrides:
getStatistics in class AbstractMemoryCache
Returns:
IStats

dumpMap

public void dumpMap()
Dump the cache map for debugging.


dumpCacheEntries

public void dumpCacheEntries()
Dump the cache entries from first to last for debugging.


freeElements

public int freeElements(int numberToFree)
                 throws IOException
This can't be implemented.

Parameters:
numberToFree -
Returns:
0
Throws:
IOException


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.