| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| How to create a custom cache providerIntroduction Intended audience Steps Configuration Cache provider implementation CacheFactory implementation Cache implementation References IntroductionIn the context of a relational data-binding tool such as Castor JDO, caches enhance application performance by reducing the number of read operations against the persistence storage, by storing and reusing the last read or committed values of the object. Castor provides a set of pre-built cache providers, offering a variety of different cache algorithms. Nevertheless, special needs might require the application developer to implement a custom cache algorithm. Castor facilitates such need by making available a standardized process of how to integrate a custom cache provider. Intended audienceAnyone who wants to develop his own custom cache provider and integrate it with Castor JDO. StepsThe main component of Castor's cache system is the interface Cache, which declares required functionality of a performance cache provider. Existing (and future) cache implementations have to implement this interface, which is closely modelled after java.util.Map. Below are defined the steps to build a custom cache provider and register it with Castor JDO. ConfigurationCastor (as of release 0.9.6) allows for addition of user-defined cache provider implementations. By default, performance caches are registered with Castor JDO through it's main configuratoin file castor.properties. This file includes a section as follows:
To add your own performance cache provider, please append the fully-qualified class name to this list as shown here:
Cache provider implementationYou will have to provide implementations of the interfaces Cache and CacheFactory for your new cache provider. CacheFactory implementationFor 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.
Cache implementationPlease create an implementation of Cache. To assist users in this task, a AbstractBaseCache class has been supplied, which users should derive their custom Cache instances from, if they wish so. Please consult existing Cache implementations such as TimeLimited} or CountLimited for complete code samples.
References
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||