org.castor.cache.hashbelt
Class AbstractHashbelt
- Cache, Map
public abstract class AbstractHashbelt
An abstract, core implementation of the hashbelt functionality; individual
implementations will differ on the underlying behavior.
A hashbelt has six important values which get set at initialization:
- org.castor.cache.hashbelt.container.Container
- org.castor.cache.hashbelt.reaper.NullReaperorg.castor.cahe.hashbelt.reaper.Reaper
$Revision: 7121 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
Default capacity of cache.
DEFAULT_CONTAINERS
public static final int DEFAULT_CONTAINERS
Default number of containers for cache.
DEFAULT_CONTAINER_CLASS
public static final Class DEFAULT_CONTAINER_CLASS
Default container class.
DEFAULT_MONITOR
public static final int DEFAULT_MONITOR
Default monitor interval of cache in minutes.
DEFAULT_REAPER_CLASS
public static final Class DEFAULT_REAPER_CLASS
Default reaper class.
DEFAULT_TTL
public static final int DEFAULT_TTL
Default ttl of cache in seconds.
PARAM_CAPACITY
public static final String PARAM_CAPACITY
Mapped initialization parameter capacity
.
PARAM_CONTAINERS
public static final String PARAM_CONTAINERS
Mapped initialization parameter containers
.
PARAM_CONTAINER_CLASS
public static final String PARAM_CONTAINER_CLASS
Mapped initialization parameter container-class
.
PARAM_MONITOR
public static final String PARAM_MONITOR
Mapped initialization parameter monitor
.
PARAM_REAPER_CLASS
public static final String PARAM_REAPER_CLASS
Mapped initialization parameter reaper-class
.
PARAM_TTL
public static final String PARAM_TTL
Mapped initialization parameter ttl
.
clear
public final void clear()
containsKey
public final boolean containsKey(Object key)
java.util.Map.containsKey(java.lang.Object)
containsValue
public final boolean containsValue(Object value)
java.util.Map.containsValue(java.lang.Object)
entrySet
public final Set entrySet()
getCapacity
public final int getCapacity()
Get real capacity of this cache.
- Real capacity of this cache.
getObjectFromCache
protected final Object getObjectFromCache(Object key)
Get object currently associated with given key from cache. Take care to acquire a
read or write lock before calling this method and release the lock thereafter.
key
- The key to return the associated object for.
- The object associated with given key.
getTTL
public final int getTTL()
Get real ttl of this cache.
isEmpty
public final boolean isEmpty()
keySet
public final Set keySet()
lock
protected final ReadWriteLock lock()
Get reference to the ReadWriteLock of this cache instance.
- ReadWriteLock to synchronize access to cache.
putObjectIntoCache
protected final Object putObjectIntoCache(Object key,
Object value)
Put given value with given key in cache. Return the object previously associated
with key. Take care to acquire a write lock before calling this method and release
the lock thereafter.
key
- The key to associate the given value with.value
- The value to associate with given key.
- The object previously associated with given key.
null
will
be returned if no value has been associated with key.
removeObjectFromCache
protected final Object removeObjectFromCache(Object key)
Remove any available association for given key. Take care to acquire a write lock
before calling this method and release the lock thereafter.
key
- The key to remove any previously associate value for.
- The object previously associated with given key.
null
will
be returned if no value has been associated with key.
size
public final int size()
values
public final Collection values()
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com