Resource cache

Personalization uses the WebSphere Dynamic Cache to cache the results of select rules and to cache the rules themselves in a DistributedMap. When publishing, importing or saving rules, the cache is flushed automatically to ensure the site is current. Since Portal Access Control is applied to documents stored in Document Manager, the Portal Document Collection is not cached by default.

The PersonalizationService.properties file contains cache control settings. The following table summarizes the configuration settings available for caching.

Table 1. PersonalizationService.properties properties and descriptions
Property Description
rulesEngine.cache.enabled Global setting to disable all caching. Setting to false will override any collections which are individually set to be cached.
rulesEngine.cache.jndiName The Dynamic Cache DistributedMap to use, as given by its JNDI name.
rulesEngine.cache.maxEnumSize Although the DistributedMap may be configured in the WebSphere Administrative console to limit the maximum number of entries in the cache, the collection of resources which is returned for each rule is counted as one entry in the cache. When a rule returns a very large number of results, caching the results may result in extra memory overhead. Therefore, when the result set of a rule exceeds the number specified in this property, it will not be cached.
rulesEngine.cache.timeout The number of seconds before an entry in the cache expires.
rulesEngine.cache.priority Priority, relative to other entries in the same DistributedMap, of a cache entry.
rulesEngine.cache.enabled.<collectionName> The same as rulesEngine.cache.enabled, except that this property applies to a specific resource collection. <collectionName> is the fully qualified path to the resource collection in Personalization. For instance, for the "GeneralNews" resource collection which is included in the sample in a folder called "PznDemo", the <collectionName> would be "/PznDemo/GeneralNews"
rulesEngine.cache.jndiName.<collectionName> The same as rulesEngine.cache.jndiName, except that this property applies to a specific resource collection.
rulesEngine.cache.maxEnumSize.<collectionName> The same as rulesEngine.cache.maxEnumSize, except that this property applies to a specific resource collection.
rulesEngine.cache.timeout.<collectionName> The same as rulesEngine.cache.timeout, except that this property applies to a specific resource collection.
rulesEngine.cache.priority.<collectionName> The same as rulesEngine.cache.priority, except that this property applies to a specific resource collection.

You might need to programmatically flush Personalization's cache, such as when a resource is updated outside of Personalization rules through some other application. A programming interface is provided to flush the cache. Since the timeout interval for the cache can be specified in the properties file, in many cases it may be adequate to wait for the cache timeout before updates are seen. The class com.ibm.websphere.personalization.resources.cache.CacheManager can be used to invalidate the cache for a particular resource, a particular resource collection, or the entire cache. Personalization uses this class internally to flush the cache when updates occur.

Flushing the cache for a particular resource may require that all cached queries be flushed. Flushing the cache on a collection may flush the cache for all collections using the same dynamic cache map. When the application frequently flushes the cache for a particular collection, isolating that collection in its own cache map through the use of the ruleEngine.cache.jndiName.<resourceCollectionName> property will result in better cache utilization.

Caching occurs before any rule exits are called.

See http://publib.boulder.ibm.com/infocenter/ws51help/index.jsp?topic=/com.ibm.websphere.wbifz.doc/info/wbifz/ae/tdyn_distmap.html for more information on the Distributed Map and WebSphere Dynamic Cache.