Cache invalidation

The difference between caching static and dynamic content is the requirement for proactive and effective invalidation mechanisms to ensure the freshness of content. The time-based invalidation alone is no longer adequate for dynamic cache invalidation.

The dynamic cache service provides event-based and time-based invalidation techniques. WAS V5.1 offers access to programmatic cache and invalidation techniques. Invalidation policies can be defined with XML cache policy files. Invalidation policies allow triggering events to invalidate cache entries without the need to write explicit code. More complex invalidation scenarios may require code, which invokes the invalidation API.

Example 14-12 shows the invalidation policy, which invalidates cache entries for groups of objects using the same Account_UserID dependency ID. For example, home servlet and all commands invoked by home servlet are invalidated when the user logs out from Trade3 application.

Example 14-12 Invalidation policy defined in the logout command

<cache-entry>	
	<class>command</class>
	<sharing-policy>not-shared</sharing-policy>
	<name>com.ibm.websphere.samples.trade.command.LogoutCommand</name>
	<invalidation>Account_UserID
		<component id="getUserID" type="method">
			<required>true</required>
		</component>
	</invalidation>
	<invalidation>Holdings_UserID1
		<component id="getUserID" type="method">
			<required>true</required>
		</component>
	</invalidation>
</cache-entry>

We also show an example for time based invalidation in Example 14-4, where marketSummary.jsp has a timeout value of 180 seconds.

Note In order to use caching safely, you need to make sure that you configure invalidation properly. To do this, be familiar with the specifications of the cachespec.xml file and the way how invalidation is handled in your application's code. This chapter provides you with one example, but please refer to the WebSphere InfoCenter for more detailed information on the cachespec.xml file.

If you use cache replication, please note that invalidations are always sent immediately regardless of the share type defined in cachespex.xml.

  Prev | Home | Next

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.