Home


3.2.4 Scheduled invalidation

We have discussed invalidating cache entries with time-based elements or through a combination of command-based invalidation using dependency and invalidation IDs. These entries are invalidated using command-based invalidation rules.

Another way to invalidate cache content is by making use of the WebSphere Commerce scheduler, which periodically invalidates cache content based on entries in the CACHEIVL table, shown in Figure | -2, using the DynaCacheInvalidation command. After installing WebSphere Commerce APAR IY886561 it is possible to invalidate cache entries after some future point in time. That is, you can specify a future time to begin to apply invalidation rules. For example, if you are planning to run a time-limited e-Marketing campaign, at the time you develop the e-Marketing campaign Web pages, you can also specify when the pages are to be evicted from the cache at the end of the campaign.

Figure 3-2 CACHEIVL table definition

The frequency at which the DynaCacheInvalidation command is called is set by the WebSphere Commerce scheduler. To modify the frequency, launch the WebSphere Commerce Administration Console and select Site Æ Configuration Æ Scheduler. Figure | -3 shows how this is done. For more information, refer to the section on the scheduler in the WebSphere Commerce Administration Guide.

Figure 3-3 Accessing the scheduler

The WebSphere Commerce scheduler runs the DynaCacheInvalidation command at a set interval. This command processes the entries in the CACHEIVL table...

The clearall string value in the TEMPLATE or DATA_ID columns of the CACHEIVL table is used by DynaCacheInvalidation to clear the cache using the DynaCache invalidation API (clear).

If the TEMPLATE column is set, then the DynaCacheInvalidation command calls the DynaCache invalidation API (invalidateByTemplate) and uses the name as the template ID. If the clearall string value (which is case insensitive) is found in the TEMPLATE column, then the DATA_ID column is ignored and the DynaCacheInvalidation command clears the cache. If the TEMPLATE column is not empty, the command invalidates using the template ID, ignoring the DATA_ID column.

If the DATA_ID column is set and the template name is not set, then the DynaCacheInvalidation command calls the DynaCache invalidation API (invalidateById) and uses the DATA_ID as the dependency ID of the cache entries to invalidate. If the TEMPLATE column is empty and the clearall string value is found in the DATA_ID column, then the command clears the cache.

When the DynaCache invalidation API is called, it invalidates the cache entries.

Create database triggers to populate the CACHEIVL table. Use the sample triggers in Example | -8 to detect and react to changes in the Store and Catalog pages. This list is only a subset of several possible triggers, and is not comprehensive. Ensure that the invalidation IDs have matching dependency ID values for the cache entries you want to invalidate.

Example 3-8 Catalog and store triggers

CREATE TRIGGER cache_1
AFTER UPDATE ON catalog
REFERENCING OLD AS N FOR EACH ROW MODE DB2SQL
INSERT INTO cacheivl (template, dataid, inserttime)
(SELECT NULLIF('A', 'A'),  'storeId:' ||  RTRIM(CHAR(storecat.storeent_id)), CURRENT TIMESTAMP
   FROM storecat
  WHERE storecat.catalog_id = N.catalog_id);

CREATE TRIGGER cache_2
AFTER UPDATE ON storecat
REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL
INSERT INTO cacheivl (template, dataid, inserttime)
(SELECT NULLIF('A', 'A'),  'storeId:' || RTRIM(CHAR(N.storeent_id)), CURRENT TIMESTAMP
   FROM catalog
  WHERE catalog.catalog_id = N.catalog_id);

CREATE TRIGGER cache_3
AFTER UPDATE ON cattogrp
REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL
INSERT INTO cacheivl (template, dataid, inserttime)
(SELECT NULLIF('A', 'A'),  'storeId:' || RTRIM(CHAR(storecat.storeent_id)), CURRENT TIMESTAMP
   FROM storecat
  WHERE storecat.catalog_id = N.catalog_id);

CREATE TRIGGER cache_4
AFTER UPDATE ON staddress
REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL
INSERT INTO cacheivl (template, dataid, inserttime)
(SELECT NULLIF('A', 'A'),  'storeId:' || RTRIM(CHAR(storeentds.storeent_id)), CURRENT TIMESTAMP
   FROM storeentds
  WHERE storeentds.staddress_id_cont = N.staddress_id);

1Obtainable as an efix from IBM service - likely to be shipped in 6.0.0.2, 5.6.0.7 and 5.6.1.3.

+

Search Tips   |   Advanced Search