|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.persist.cache.AbstractBaseCache
org.exolab.castor.persist.cache.CountLimited
CustomCache 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, a least-recently-used object will be disposed.
Method dispose(Object)
will be called whenever an
old object is diposed. Developer can get notify by overriding
the dispose method dispose(Object)
.
Field Summary | |
static int |
DEFAULT_SIZE
|
Constructor Summary | |
CountLimited()
|
|
CountLimited(int capacity)
|
Method Summary | |
boolean |
contains(java.lang.Object key)
Indicates whether the cache holds value object mapped to the specified key. |
protected void |
dispose(java.lang.Object o)
This method is called when an object is disposed. |
java.util.Enumeration |
elements()
Returns an enumeration of the values in this LRU map. |
void |
expire(java.lang.Object key)
Remove the object identified by key from the cache. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the specified key is mapped in this Map. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Maps the specified key to the specified
value in this Map. |
java.lang.Object |
remove(java.lang.Object key)
Removes the key (and its corresponding value) from this Map. |
void |
setCapacity(int capacity)
Sets the cache capacity. |
Methods inherited from class org.exolab.castor.persist.cache.AbstractBaseCache |
getCacheType, getCapacity, getClassName, setCacheType, setClassName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.exolab.castor.persist.cache.Cache |
getCacheType, getCapacity, getClassName, setCacheType, setClassName |
Field Detail |
public static int DEFAULT_SIZE
Constructor Detail |
public CountLimited()
public CountLimited(int capacity)
Method Detail |
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
to the specified
value
in this Map. Neither the key nor the
value can be null
.
The value can be retrieved by calling the get
method
with a key that is equal to the original key, before it is diposed
when the Map is full.
put
in interface Cache
put
in class AbstractBaseCache
key
- the Map key.value
- the value.
null
if it did not have one.
java.lang.NullPointerException
- if the key or value is
null
.public java.lang.Object get(java.lang.Object key)
get
in interface Cache
get
in class AbstractBaseCache
key
- - a key in the Map.
public java.lang.Object remove(java.lang.Object key)
remove
in interface Cache
remove
in class AbstractBaseCache
key
- the key that needs to be removed.
null
if the key did not have a mapping.public java.util.Enumeration elements()
elements
in interface Cache
elements
in class AbstractBaseCache
Enumeration
public void expire(java.lang.Object key)
expire
in interface Cache
expire
in class AbstractBaseCache
key
- the key that needs to be removed.protected void dispose(java.lang.Object o)
o
- - the disposed objectpublic boolean contains(java.lang.Object key)
contains
in interface Cache
contains
in class AbstractBaseCache
key
- - A key identifying a value object.
Cache.contains(java.lang.Object)
public void setCapacity(int capacity)
setCapacity
in interface Cache
setCapacity
in class AbstractBaseCache
capacity
- the cache capacity.Cache.setCapacity(int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |