Explicit invalidation in the Persistence Manager cache

Container managed persistence (CMP) entity beans can be configured as long-lifetime beans. A long-lifetime bean is one that is configured with Lifetime In Cache Usage equal to a value other than the default OFF . A value other than OFF means that data for this bean is cached beyond the end of the transaction in which the bean was obtained by a finder or other method. The Lifetime In Cache Usage and Lifetime In Cache values control the basic length of time the cached data remains valid. When the specified time runs out, the cached data is no longer valid. See the LifetimeInCache help sections of the Assembly Service Toolkit (AST) for more details.

However, there is also an API that lets the client application code explicitly invalidate the cached data of a bean on demand, superseding the basic lifetime of the cache data as controlled by the Lifetime In Cache Usage and Lifetime In Cache settings. This is useful where an application that does not use CMP beans modifies the data that underlies a CMP bean (for example, it updates a database table to which a CMP bean is mapped). Such an application can inform WebSphere Application Server that any cached version of this bean data is stale and no longer matches what is in the database. The data should be invalidated (in essence, discarded). For CMP beans that cannot tolerate stale data, this is an important feature.

Because the PM Cache Invalidation mechanism does consume resources in exchange for its benefits, it is not enabled by default. To enable it refer to Setting Persistence Manager Cache Invalidation .

 

See also


Example: Explicit invalidation in the persistence manager cache
Setting Persistence Manager Cache invalidation