org.castor.cache.simple
Class CountLimited

java.lang.Object
  extended by org.castor.cache.AbstractBaseCache
      extended by org.castor.cache.simple.CountLimited
All Implemented Interfaces:
Map<Object,Object>, Cache

public final class CountLimited
extends AbstractBaseCache

CountLimited is a count limted least-recently-used Map. Every object being put in the Map will live until the map is full. If the map is full, the least recently used object will be disposed.

The capacity is passed to the cache at initialization by the individual cache property capacity which defines the maximum number of objects the cache can hold. If not specified a default capacity of 30 objects will be used.

Version:
$Revision: 8102 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Author:
Thomas Yip, Werner Guttmann, Ralf Joachim

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static int DEFAULT_CAPACITY
          Default capacity of cache.
static String PARAM_CAPACITY
          Mapped initialization parameter capacity.
static String TYPE
          The type of the cache.
 
Fields inherited from interface org.castor.cache.Cache
DEFAULT_DEBUG, DEFAULT_NAME, DEFAULT_TYPE, PARAM_DEBUG, PARAM_NAME, PARAM_TYPE
 
Constructor Summary
CountLimited()
           
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<Object,Object>> entrySet()
          
 Object get(Object key)
          
 int getCapacity()
          Get real capacity of this cache.
 String getType()
          Indicates the type of this cache.
 void initialize(Properties params)
          Lyfe-cycle method to allow custom initialization of cache implementations.
 boolean isEmpty()
          
 Set<Object> keySet()
          
 Object put(Object key, Object value)
          
 void putAll(Map<? extends Object,? extends Object> map)
          
 Object remove(Object key)
          
 int size()
          
 Collection<Object> values()
          
 
Methods inherited from class org.castor.cache.AbstractBaseCache
close, expire, expireAll, getName, invokeMethod, invokeStaticMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

TYPE

public static final String TYPE
The type of the cache.

See Also:
Constant Field Values

PARAM_CAPACITY

public static final String PARAM_CAPACITY
Mapped initialization parameter capacity.

See Also:
Constant Field Values

DEFAULT_CAPACITY

public static final int DEFAULT_CAPACITY
Default capacity of cache.

See Also:
Constant Field Values
Constructor Detail

CountLimited

public CountLimited()
Method Detail

initialize

public void initialize(Properties params)
                throws CacheAcquireException
Lyfe-cycle method to allow custom initialization of cache implementations.

Specified by:
initialize in interface Cache
Overrides:
initialize in class AbstractBaseCache
Parameters:
params - Parameters to initialize the cache (e.g. name, capacity).
Throws:
CacheAcquireException - If cache can not be initialized.

getType

public String getType()
Indicates the type of this cache.

Returns:
The cache type.

getCapacity

public int getCapacity()
Get real capacity of this cache.

Returns:
Real capacity of this cache.

size

public int size()


isEmpty

public boolean isEmpty()


containsKey

public boolean containsKey(Object key)


containsValue

public boolean containsValue(Object value)


get

public Object get(Object key)


put

public Object put(Object key,
                  Object value)


remove

public Object remove(Object key)


putAll

public void putAll(Map<? extends Object,? extends Object> map)


clear

public void clear()


keySet

public Set<Object> keySet()


values

public Collection<Object> values()


entrySet

public Set<Map.Entry<Object,Object>> entrySet()



Copyright © 2010. All Rights Reserved.