Interface Cache
-
- All Superinterfaces:
java.util.Map<java.lang.Object,java.lang.Object>
- All Known Implementing Classes:
AbstractBaseCache
,AbstractDistributedCache
,AbstractHashbelt
,CoherenceCache
,CountLimited
,DebuggingCacheProxy
,EHCache
,FIFOHashbelt
,FKCache
,GigaspacesCache
,JCache
,JcsCache
,LRUHashbelt
,NoCache
,OsCache
,TimeLimited
,Unlimited
public interface Cache extends java.util.Map<java.lang.Object,java.lang.Object>
Interface specification for performance caches as used in Castor. Please implement this interface if you wish to provide your own cache implementation.At initialization each cache implementation gets passed a properties map containing key/value pairs. Apart of 3 reserved standard properties, individual once can be used to configure the cache behavier. The standard properties are:
type which is evaluated by the CacheFactoryRegistry and defines the requested cache type. If not set count-limited cahce will be used as default.
debug is also evaluated by the CacheFactoryRegistry and defines if the cache instance will be wrapped by a DebuggingCacheProxy to log debug messages at every access to the cache. If not set no debugging will take place.
name is used by AbstractBaseCache to set the name of the cache instance. At the moment every cache type available extends this AbstractBaseCache. The name does not influence internal behavier of the cache but is usefull to identify from which cache instance debug messages are coming from. By default castor uses the classname of the cached objects as name for the cache. If not present the name will be empty.For a description of the individual properties you should have a look at the javadoc of the different cache types. It needs to be noted that only string keys and values are allowed.
- Since:
- 1.0
- Version:
- $Revision: 8102 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
- Author:
- Werner Guttmann, Ralf Joachim
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_DEBUG
Default is debugging switched off.static java.lang.String
DEFAULT_NAME
Default cache name to be used.static java.lang.String
DEFAULT_TYPE
Default cache type to be used.static java.lang.String
PARAM_DEBUG
Mapped initialization parameterdebug
.static java.lang.String
PARAM_NAME
Mapped initialization parametername
.static java.lang.String
PARAM_TYPE
Mapped initialization parametertype
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Life-cycle method to allow custom resource cleanup for a cache implementation.void
expire(java.lang.Object key)
Remove the mapping identified by key from the cache.void
expireAll()
Removes all mappings from the cache.java.lang.String
getName()
Get virtual name 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.
-
-
-
Field Detail
-
PARAM_TYPE
static final java.lang.String PARAM_TYPE
Mapped initialization parametertype
.- See Also:
- Constant Field Values
-
DEFAULT_TYPE
static final java.lang.String DEFAULT_TYPE
Default cache type to be used.- See Also:
- Constant Field Values
-
PARAM_NAME
static final java.lang.String PARAM_NAME
Mapped initialization parametername
.- See Also:
- Constant Field Values
-
DEFAULT_NAME
static final java.lang.String DEFAULT_NAME
Default cache name to be used.- See Also:
- Constant Field Values
-
PARAM_DEBUG
static final java.lang.String PARAM_DEBUG
Mapped initialization parameterdebug
.- See Also:
- Constant Field Values
-
DEFAULT_DEBUG
static final java.lang.String DEFAULT_DEBUG
Default is debugging switched off.- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
void initialize(java.util.Properties params) throws CacheAcquireException
Lyfe-cycle method to allow custom initialization of cache implementations.- Parameters:
params
- Parameters to initialize the cache (e.g. name, capacity).- Throws:
CacheAcquireException
- If cache can not be initialized.
-
close
void close()
Life-cycle method to allow custom resource cleanup for a cache implementation.
-
getType
java.lang.String getType()
Indicates the type of this cache.- Returns:
- The cache type.
-
getName
java.lang.String getName()
Get virtual name of this cache. Castor sets the cache name to the class name of the objects stored in the cache.- Returns:
- The cache name.
-
expire
void expire(java.lang.Object key)
Remove the mapping identified by key from the cache.- Parameters:
key
- the key that needs to be removed.
-
expireAll
void expireAll()
Removes all mappings from the cache.
-
-