Home | 2.6 Configuring DynaCache using XML-based policies | 2.6.2 Cache entry element overview <cache-entry>


2.6.1 Basic structure of the cachespec.xml file.

To start caching the Consumer Direct application you first need to create a cache specification file called cachespec.xml.

The cachespec.xml file contains configuration entries for your caching definitions and rules and is often referred to as the cachespec.

Store the cachespec.xml file in the WEB-INF directory of your Web module. Changes to the cachespec are automatically picked up by DynaCache.

Cachespec.xml can be stored in the WebSphere Application Server properties directory. A cachespec in the property directory defines rules that are global to all applications. It is uncommon to do this because caching policies are normally application specific.

A simple cachespec.xml file with one JSP cache entry...

<cache>

  <cache-entry>

    <class>servlet</class>
    <name>/StoreCatalogDisplay.jsp</name>
    <property name="save-attributes">false</property>
    <property name="store-cookies">false</property>
    <timeout>3600</timeout>
    <priority>3</priority>

    <cache-id>
      <component id="storeId" type="parameter">
        <required>true</required>
      </component>
      <component id="catalogId" type="parameter">
        <required>true</required>
      </component>
    </cache-id>

    <dependency-id>storeId
      <component id="storeId" type="parameter">
        <required>true</required>
      </component>
    </dependency-id>

    <invalidation>storeId

      <component id="action" type="parameter" ignore-value="true">
        <value>update</value>
        <required>true</required>
      </component>
      <component id="storeId" type="parameter">
        <required>true</required>
      </component>

    </invalidation>

  </cache-entry>

</cache>

In WebSphere vernacular, the cachespec is a deployable, XML policy configuration file that allows you to specify:

What is going to be cached (Servlets, JSP, Java commands, and so forth)

Where it is going to be cached (memory or disk)

When cache items are to be evicted (invalidation)

How cache entries are related (invalidation dependencies)

In the cachespec there a few important high-level XML elements that we will need to master. They are:

The cache entry element: <cache-entry>

The cache ID element: <cache-id>

The dependency ID element: <dependency-id>

The invalidation rule element: <invalidation>

To introduce you briefly to these XML artifacts, we start off at a high level and then work our way through the general cachespec structure. Later, we build on that knowledge by taking each of these XML components in turn and exposing more of the detail.

+

Search Tips   |   Advanced Search