Compoze Software, Inc.

com.compoze.util
Class LruCache

java.lang.Object
  extended bycom.compoze.util.LruCache
All Implemented Interfaces:
com.compoze.util.IObjectCache, java.io.Serializable

public class LruCache
extends java.lang.Object
implements com.compoze.util.IObjectCache, java.io.Serializable

See Also:
Serialized Form

Constructor Summary
LruCache(int iCacheLimit)
          Constructor.
 
Method Summary
 void clear()
          Removes all objects from this object cache.
 void flush()
          Flushes the objects from this object cache if the object cache has exceeded the cache limit.
 java.lang.Object get(java.lang.Object key)
          Returns the object to which this object cache maps the specified key.
 int getCacheLimit()
          Gets the cache limit.
 int getSize()
          Removes the specified object from this object cache.
 void put(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key in this object cache.
 void remove(java.lang.Object keyToRemove)
          Removes the specified object from this object cache.
 void setCacheLimit(int iCacheLimit)
          Sets the cache limit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LruCache

public LruCache(int iCacheLimit)
Constructor.

Parameters:
iCacheLimit - the limit of objects that are kept in the cache (0 = don't cache)
Method Detail

setCacheLimit

public void setCacheLimit(int iCacheLimit)
Sets the cache limit.

Specified by:
setCacheLimit in interface com.compoze.util.IObjectCache
Parameters:
iCacheLimit - the limit of objects that are kept in the cache (0 = don't cache)

getCacheLimit

public int getCacheLimit()
Gets the cache limit.

Specified by:
getCacheLimit in interface com.compoze.util.IObjectCache
Returns:
the limit of objects that are kept in the cache (0 = don't cache)

get

public java.lang.Object get(java.lang.Object key)
Returns the object to which this object cache maps the specified key.

Specified by:
get in interface com.compoze.util.IObjectCache
Returns:
the value to which this object cache maps the specified key, or null if the object cache contains no mapping for the key

put

public void put(java.lang.Object key,
                java.lang.Object value)
Associates the specified value with the specified key in this object cache. If the object cache previously contained a mapping for this key, the old value is replaced.

Specified by:
put in interface com.compoze.util.IObjectCache
Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key

flush

public void flush()
Flushes the objects from this object cache if the object cache has exceeded the cache limit. The polilcy for remocal is least recently used (LRU).

Specified by:
flush in interface com.compoze.util.IObjectCache

clear

public void clear()
Removes all objects from this object cache.

Specified by:
clear in interface com.compoze.util.IObjectCache

remove

public void remove(java.lang.Object keyToRemove)
Removes the specified object from this object cache.

Specified by:
remove in interface com.compoze.util.IObjectCache
Parameters:
keyToRemove - the key to the object for removal

getSize

public int getSize()
Removes the specified object from this object cache.


Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.