Home


Command-based invalidation

Step one in the process of defining invalidation rules is to identify the events or actions that will invalidate a cache entry. Step two, when using command-based invalidation, is to identify the controller or task commands that are invoked when those events occur. For example, when you use the WebSphere Commerce Accelerator to update a product attribute, the ProductAttributeUpdateCmdImpl command is invoked. You can use this command to trigger an invalidation of product-related fragments or pages when the command is invoked.

Example | -2 shows a portion of the sample invalidation cachespec.xml that can be found at WC_installdir/samples/DynaCache/invalidation.

The cache entry in Example | -2 shows how to invalidate product-related cache entries after the product-related attributes have been updated. When the product has been updated, one of the commands listed in the cache entry, such as ProductAttributeUpdateCmdImpl or AttributeValueUpdateCmdImpl, is invoked. These command names are specified within the <name> element. As a result, the subsequent invalidation rules, which are defined within the <invalidation> tags, are executed.

In the first invalidation rule all cache entries having the dependency ID productId are invalidated if their product ID matches the ID returned by a call to the method getCatentryId as specified in the component sub-element.

Example 3-2 Invalidation using commands

<cache-entry>
  <class>command</class>
  <sharing-policy>not-shared</sharing-policy>
  <name>com.ibm.commerce.catalogmanagement.commands.ProductAttributeUpdateCmdImpl</name>
  <name>com.ibm.commerce.catalogmanagement.commands.AttributeValueUpdateCmdImpl</name>
  <name>com.ibm.commerce.catalogmanagement.commands.UpdateAttributeCmdImpl</name>
  <name>com.ibm.commerce.catalogmanagement.commands.UpdateAttributeValueCmdImpl</name>

  <invalidation>productId
    <component id="getCatentryId" type="method">
      <required>true</required>
    </component>
  </invalidation>

  <invalidation>MiniCart:DC_storeId
    <component id="getStoreId" type="method">
      <required>true</required>
    </component>
  </invalidation>

  <invalidation>storeId:productId
    <component id="getStoreId" type="method">
      <required>true</required>
    </component>
    <component id="getCatentryId" type="method">
      <required>true</required>
    </component>
  </invalidation>

  <invalidation>CategoryDisplay:storeId
    <component id="getStoreId" type="method">
      <required>true</required>
    </component>
  </invalidation>

</cache-entry>

The other invalidation elements describe how cache entries should be invalidated based on different dependency IDs.

+

Search Tips   |   Advanced Search