DynaCacheInvalidation URL

The DynaCacheInvalidation command is a scheduled command that can be invoked on a URL to invalidate entries in the WebSphere Application Server dynamic cache.

The DynaCacheInvalidation command invalidates entries in the dynamic cache based on the dependency ID, cache ID, or template for a cached page that are recorded in the CACHEIVL table. The default cache invalidation interval is 10 minutes. We can change this default in the WebSphere Commerce Administration Console. In addition, this command can be started as a URL given the startTime and startTimeNanos parameters together or given the clear parameter alone. To run this command on the URL, we must log on to the store as a WebSphere Commerce site administrator.

Note: Ensure that you enable cache replication.


URL structure


Parameter values

Note: Normally you specify either the startTime and startTimeNanos parameters together, or the clear parameter by itself. If you specify all three parameters, the command takes the clear parameter.


Example

The following example invalidates the cached pages in the CACHEIVL table for all rows, beginning from the first row:

The following example clears all the cached pages in the dynamic cache:

The following example invalidates all cache entries that have any dependency on data from a particular table:


Behavior

Additional behavior information

The DynaCacheInvalidation scheduler job looks in the CACHEIVL table for recently added rows. When the job finds a value in the TEMPLATE column that starts with the dmap: prefix for a new row, the job uses the rest of the value that follows the prefix as a JNDI name. This name specifies a DistributedMap object cache instance. If the specified object cache does not exist, no action is taken. If the specified object cache does exist, then the value of the DATAID column is sent to the specified object cache as an invalidation id string. If you define the DistributedMap in a cacheinstances.properties file, the first forward slash of the JDNI name should be omitted.

For example, if the distributed map is defined in the cacheinstances.properties file as cache.instance.0=/services/cache/MyCustomMapCache, then the string in the TEMPLATE column of the CACHEIVL table should be dmap:services/cache/MyCustomMapCache.

If the scheduler job locates a value in the TEMPLATE column that starts with cmd: prefix for a new row, the job uses the rest of the value that follows the prefix as a Java class name. If the specified Java class is not an instance of com.ibm.commerce.dynacache.commands.StringHolderCmdImpl, no action is taken. If the specified Java class is an instance of a subclass of com.ibm.commerce.dynacache.commands.StringHolderCmdImpl, then an instance of that class is created and its setString method is called which passes the value of the DATAID column, and the command instance is executed. A custom servlet cache can cause the specified DATAID value to be sent as an invalidation to a servlet cache instance. This invalidation can be sent by specifying that command in the cachespec.xml file for the custom servlet cache instance. For example:

Since a command cannot be defined for more than one servlet cache instance, WebSphere Commerce includes three subclasses of com.ibm.commerce.dynacache.commands.StringHolderCmdImpl. These subclasses can be used to cause invalidations in up to three more custom servlet cache instances:

The DynaCacheInvalidation scheduler job looks in the CACHEIVL table for recently added rows. When the job finds a value in the TEMPLATE column that begins with the cache: prefix for a new row, the job uses the remaining value that follows the prefix as a colon delimited list of JNDI names. Each JNDI name specifies either a servlet cache instance or a DistributedMap object cache instance. If a specified cache does not exist, no action is taken for that cache. For each specified cache that does exist, the value of the DATAID column is sent to the specified object cache as an invalidation id string, unless it is the special "clearall" string, in which case the cache is cleared.

Note: The JNDI names that you specify should not be prefixed with a forward slash. For example, if a distributed map is defined in the cacheinstances.properties file as cache.instance.0=/services/cache/MyCustomMapCache, then the string in the TEMPLATE column of the CACHEIVL table should be cache:services/cache/MyCustomMapCache.


Exception conditions

DynaCacheInvalidation throws an ECException if there are problems when the invalidation executes the SQL, or if there is a system error.


Related concepts
Cache invalidation