As explained in org.exolab.castor.persist
,
LockEngine
implements a persistence engine
that caches objects in memory for performance reasons and thus eliminates the
number of operations against the persistence storage.
The main component of this package is the interface Cache
, which declares
the external functionality of a performance cache. Existing (and future) cache engines
have to implement this interface, which extends Map
. To obtain an
instance of a particular cache engine, use CacheFactoryRegistry
and its
factory methods.
The remainder of this package are exceptions associated with cache interaction, an enumeration of all (currently) available cache types and a prototype for an (abstract) base class to assist future cache engine additions.
Castor (as of release 0.9.6) allows for addition of user-defined cache implementations.
By default, the file castor.properties includes a section as follows:
# # Cache implementations # org.castor.cache.Factories=\ org.castor.cache.simple.NoCacheFactory,\ org.castor.cache.simple.TimeLimitedFactory,\ org.castor.cache.simple.CountLimitedFactory,\ org.castor.cache.simple.UnlimitedFactory,\ org.castor.cache.distributed.FKCacheFactory,\ org.castor.cache.distributed.JcsCacheFactory,\ org.castor.cache.distributed.JCacheFactory,\ org.castor.cache.distributed.CoherenceCacheFactory,\ org.castor.cache.distributed.OsCacheFactory,\ org.castor.cache.hashbelt.FIFOHashbeltFactory,\ org.castor.cache.hashbelt.LRUHashbeltFactory
To add your own performance cache implementation, please append the fully-qualified class name to this list as shown here:
# # Cache implementations # org.castor.cache.Factories=\ org.castor.cache.simple.NoCacheFactory,\ org.castor.cache.simple.TimeLimitedFactory,\ org.castor.cache.simple.CountLimitedFactory,\ org.castor.cache.simple.UnlimitedFactory,\ org.castor.cache.distributed.FKCacheFactory,\ org.castor.cache.distributed.JcsCacheFactory,\ org.castor.cache.distributed.JCacheFactory,\ org.castor.cache.distributed.CoherenceCacheFactory,\ org.castor.cache.distributed.OsCacheFactory,\ org.castor.cache.hashbelt.FIFOHashbeltFactory,\ org.castor.cache.hashbelt.LRUHashbeltFactory,\ org.whatever.somewhere.nevermind.CustomCache
In addition, you will have to provide the cache implementation and a CacheFactory
implementation for your new cache instance. For this, please add an implementation
of CacheFactory
and make sure that you provide valid values for the two
properties name and className.
To assist users in this task, a AbstractCacheFactory
class has been supplied, which users
should derive their custom CacheFactory
instances from, if they wish so. Please consult
existing CacheFactory
implementations such as TimeLimitedFactory
or CountLimitedFactory
for code samples.
/** * My own cache implementation */ public class CustomCache extends AbstractBaseCache { ... }
/** * My own cache factory implementation */ public class CustomCacheFactory extends AbstractCacheFactory { /** * The name of the factory */ private static final String NAME = "custom"; /** * Full class name of the underlying cache implementation. */ private static final String CLASS_NAME = "my.company.project.CustomCache"; /** * Returns the short alias for this factory instance. * @return The short alias name. */ public String getName() { return NAME; } /** * Returns the full class name of the underlying cache implementation. * @return The full cache class name. */ public String getCacheClassName() { return CLASS_NAME; } }
Interface | Description |
---|---|
Cache |
Interface specification for performance caches as used in Castor.
|
CacheFactory |
A factory for instantiating Cache implementations.
|
Class | Description |
---|---|
AbstractBaseCache |
Base implementation of all LRU cache types.
|
AbstractCacheFactory |
Base implementation of
CacheFactory . |
CacheFactoryRegistry |
Registry for
CacheFactory implementations obtained from the Castor
properties file and used by the JDO mapping configuration file. |
DebuggingCacheProxy |
A debugging cache proxy.
|
Exception | Description |
---|---|
CacheAcquireException |
Exception that indicates that a performance cache instance can not be acquired.
|
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com