10.5.5 Cache invalidation

 

+

Search Tips   |   Advanced Search

 

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 V6 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.

The example below 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 the application.

  <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>  

An example for time based invalidation can be seen in Example 10-5, where marketSummary.jsp has a timeout value of 180 seconds.

If you use cache replication, note that invalidations are always sent immediately regardless of the share type defined in cachespec.xml or the replication type selected in the Dynamic Cache Services settings.

Next