+

Search Tips   |   Advanced Search

cachespec.xml file

The cache parses the cachespec.xml file when the server starts, and extracts a set of configuration parameters from each cache-entry element. Every time a new servlet or other cacheable object initializes, the cache attempts to match each of the cache-entry elements to find the configuration information for that object.

The cache-entry elements can be inside the root cache element or inside a cache-instance element. Cache entries in the root element are cached with the default cache instance. Cache entries in the <cache-instance> element are cached in that particular cache instance. Different cacheable objects have different class elements. We can define the specific object that a cache policy refers to using the name element.

Place the cachespec.xml file with the deployment module. Use an assembly tool to define the cacheable objects. We can also place a global cachespec.xml file in the application server properties directory. In situations where there is a global cachespec.xml file in the application server properties directory, and a cachespec.xml file in an application, the entries in the two cachespec.xml files are merged. If there are conflicting entries in the two files, the entries in the in the cachespec.xml file that is in the application override the entries in the global cachespec.xml file for that application.

The cachespec.dtd file is available in application server properties directory. The cachespec.dtd file defines the legal structure and the elements that can be in the cachespec.xml file.


cachespec.xml elements


idgenerator and metadatagenerator sub-elements

Use the idgenerator element to specify the class name that is loaded for the generation of the cache ID. The IdGenerator element must implement the com.ibm.websphere.servlet.cache.IdGenerator interface for a servlet or the com.ibm.websphere.webservices.IdGenerator interface for the web services client cache. An example of the idgenerator element follows:

Where class name is the fully-qualified name of the class to use. Define this generator class in a shared library.

Use the metadatagenerator element inside the cache-id element to specify the class name loaded for the metadata generation. The MetadataGenerator class must implement the com.ibm.websphere.servlet.cache.MetaDataGenerator interface for a servlet or the com.ibm.websphere.cache.webservices.MetaDataGenerator interface for a web services client cache. The MetadataGenerator class defines properties like timeout, inactivity, external caching properties or dependencies. An example of the metadatagenerator element follows:

In this example, class name is the fully-qualified name of the class to use. Define this generator class in a shared library.


dependency-id element

Specify additional cache identifiers that associate multiple cache entries to the same group identifier.

The value of the dependency-id element is generated by concatenating the dependency ID base string with the values that are returned by its component elements. If a required component returns a null value, the entire dependency does not generate and is not used. Validate the dependency IDs explicitly through the dynamic cache API, or use the invalidation element. Multiple dependency ID rules can exist in one cache-entry element. All dependency rules run separately.


invalidation element

To invalidate cached objects, the application server must generate unique invalidation IDs. Build invalidation IDs by writing custom Java code or through rules defined in the cache policy of each cache entry. The following example illustrates an invalidation in the cache policy:


invalidationgenerator subelement

Used with the web services client cache only. Use the invalidationgenerator element to specify the class name to load for generating invalidation IDs. The InvalidationGenerator class must implement the com.ibm.websphere.cache.webservices.InvalidationGenerator interface. An example of the invalidationgenerator element follows:

In this example, classname is the fully qualified name of the class that implements the com.ibm.websphere.cache.webservices.InvalidationGenerator interface. Define this generator class in a shared library.


Example of a cachespec.xml file

  • Assemble applications
  • Configure cache replication
  • Example: Configuring the dynamic cache service