Package org.castor.cache.simple
Class CountLimited
- java.lang.Object
-
- org.castor.cache.AbstractBaseCache
-
- org.castor.cache.simple.CountLimited
-
- All Implemented Interfaces:
java.util.Map<java.lang.Object,java.lang.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
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CAPACITY
Default capacity of cache.static java.lang.String
PARAM_CAPACITY
Mapped initialization parametercapacity
.static java.lang.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
Constructors Constructor Description CountLimited()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>>
entrySet()
java.lang.Object
get(java.lang.Object key)
int
getCapacity()
Get real capacity of this cache.java.lang.String
getType()
Indicates the type of this cache.void
initialize(java.util.Properties params)
Lyfe-cycle method to allow custom initialization of cache implementations.boolean
isEmpty()
java.util.Set<java.lang.Object>
keySet()
java.lang.Object
put(java.lang.Object key, java.lang.Object value)
void
putAll(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> map)
java.lang.Object
remove(java.lang.Object key)
int
size()
java.util.Collection<java.lang.Object>
values()
-
Methods inherited from class org.castor.cache.AbstractBaseCache
close, expire, expireAll, getName, invokeMethod, invokeStaticMethod
-
-
-
-
Field Detail
-
TYPE
public static final java.lang.String TYPE
The type of the cache.- See Also:
- Constant Field Values
-
PARAM_CAPACITY
public static final java.lang.String PARAM_CAPACITY
Mapped initialization parametercapacity
.- See Also:
- Constant Field Values
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
Default capacity of cache.- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(java.util.Properties params) throws CacheAcquireException
Lyfe-cycle method to allow custom initialization of cache implementations.- Specified by:
initialize
in interfaceCache
- Overrides:
initialize
in classAbstractBaseCache
- Parameters:
params
- Parameters to initialize the cache (e.g. name, capacity).- Throws:
CacheAcquireException
- If cache can not be initialized.
-
getType
public java.lang.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(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
get
public java.lang.Object get(java.lang.Object key)
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
-
remove
public java.lang.Object remove(java.lang.Object key)
-
putAll
public void putAll(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> map)
-
clear
public void clear()
-
keySet
public java.util.Set<java.lang.Object> keySet()
-
values
public java.util.Collection<java.lang.Object> values()
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
-
-