Enabling query caching

Query caching allows EAServer to cache the values returned by finder and ejbSelect method queries. When caching is enabled for a query, the key values returned by each invocation are cached in memory, with the method input parameter values serving as the cache key. Together with entity object caching, query caching can reduce the number of unnecessary database reads.

To enable caching for a finder or ejbSelect query, configure the <queryMethod> command attributes listed in Table 4-5.

Table 4-5: <queryMethod> attributes to configure query cache settings

Attribute

Description

isolationLevel

To enable query caching for a method, you must explicitly specify an isolation level in the <queryMethod> configuration that includes “Cache” in the name. See “Logical isolation level”.

cacheSize

The maximum number of database rows that will be held in cache. To avoid overflow, rows are removed from cache using a least-recently-used (LRU) discard strategy. If not set, the default is 1000.

cacheTimeout

The maximum number of seconds that a row stored in cache will be considered valid. This setting should not be used to attempt to control the cache size, because invalid rows are only discarded from cache when an attempt is made to access them. The default value of zero is interpreted as an infinite timeout.

preloadCache

If the logical isolation level for the associated persistent object indicates the use of a cache, and if this query has no parameters, then this property (if true) requests preloading of results into the cache.