InfoCenter Home >
6: Administer applications >
6.6: Tools and resources quick reference >
6.6.0: About user assistance >
6.6.0.4: Overview of editing property files by hand >
6.6.0.4.1: Dynamic caching of Servlets and JSPs >
6.6.0.4.1.1: Description of the dynacache.xml file

6.6.0.4.1.1: Description of the dynacache.xml file

The servlet cache can be enabled or disabled by the presence of the dynacache.xml file. If the file is not present, the servlet engine functions in the usual manner. However, caching is enabled if the dynacache.xml file is present in directory:

\WebSphere\AppServer\properties

Use the dynacache.xml file to configure the size of the cache and to register external caches to be used by applications.

Note:  The dynacache.xml file is read only once, at WebSphere Application Server startup. So if changes are made to the file, WebSphere Application Server must be restarted for the changes to take effect.

The DTD (document type definition) for the dynacache.xml file is specified in the dynacache.dtd file which ships with WebSphere Application Server and is located in directory:

\WebSphere\AppServer\properties

The dynacache.dtd file defines the root element, <cacheUnit>.

The dynacache.dtd file is included in the xml file through a DOCTYPE declaration, as for example:

<!DOCTYPE cacheUnit SYSTEM "dynacache.dtd">

Therefore, the beginning of the dynacache.xml file looks like:

 <?xml version="1.0"?>
<!DOCTYPE cacheUnit SYSTEM "dynacache.dtd">

Configuring the global cache operation

The root <cacheUnit> element should contain one <cache> element that provides global settings for all Application Servers on a node. The format of the <cache> element is:

<cache size="entries" priority="default_priority"/>
In this example, the variables, entries and default_priority, are defined as:
  • entries - an integer defining the maximum number of entries the cache will hold. Values are usually in the thousands, with no set maximum or minimum value.

    Note:   The size of the cache is not limited by a memory cap (e.g., 20 megabytes), but by the number of distinct elements that can be held in the cache. The cache only adds a few bytes of overhead for each entry (less than 32 bytes) so the size of an entry in memory is equal to the amount of data being stored in that entry.
  • default_priority - an integer that defines the default priority for cacheable servlets defined in the servletcache.xml file. The recommended value for priority is 1.

    Note:  Priority is an extension of the Least Recently Used (LRU) caching algorithm. It represents the number of cycles through the LRU algorithm an entry is guaranteed to stay in the cache. For more information on the priority parameter, see the priority documentation in the servletcache.xml file description.

So to declare a cache storing at most 10,000 entries and giving all entries a default priority of one, you would enter:
<cache size="10000" priority="1"/>

Controlling external caches

WebSphere Application Server can control external caches. You can define different external caches, each of which can have its own set of member caches. The interface between WebSphere Application Server and one of the member caches is an adapter bean, typically written by the vendor of the external cache.

An adminstrator registers external cache groups with the <externalCacheGroups> element. You can also use the <externalCacheGroups> element in the servletcache.xml file. Each group is further defined with the <group> element. Group elements can contain <member> elements.

The format of a <group> element is:

<group id="group_name">
...

</group>
The variable, group_name, is a string identifier for a group of external caches. For a servlet to be externally cacheable, a group_name must be used to identify the external group when the servlet is configured in the servletcache.xml file.

The format of the <member> element is:

<member address="address" adapterBeanName="adapter_class"/>
The variable, address, is the hostname or IP address of the external cache location.

The variable, adapter_class, is the package and class name of the adapter for the external cache. The adapter_class string is passed to the adapter bean's setAddress method. Check the adapter bean documentation for the format of the string.

The format of an <externalCacheGroups> stanza is:

<externalCacheGroups>
<group id="edgeservers">
<member address="edgeone" adapterBeanName="my.package.EdgeAdapter"/>
<member address="edgetwo" adapterBeanName="other.package.OtherAdapter"/>
</group>
</externalCacheGroups>

Go to previous article: Dynamic caching of Servlets and JSPs Go to next article: Quick reference - dynacache.xml file

 

 
Go to previous article: Dynamic caching of Servlets and JSPs Go to next article: Quick reference - dynacache.xml file