Oracle

com.compoze.util
Class LruCache

java.lang.Object
  extended by com.compoze.util.LruCache
All Implemented Interfaces:
java.io.Serializable

public class LruCache
extends java.lang.Object
implements 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.

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

getCacheLimit

public int getCacheLimit()
Gets the cache limit.

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.

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.

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).


clear

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


remove

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

Parameters:
keyToRemove - the key to the object for removal

getSize

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


Oracle

Copyright ©1999-2008 Oracle All rights reserved.