Home | 2.6.8 Command-based invalidation | 2.6.10 The effect of updates to the cachespec.xml file


2.6.9 Delay-invalidations

For performance reasons DynaCache is not transactional. In terms of data integrity, DynaCache is intentionally "best-effort" so that it can execute quickly. As a consequence, the caching of incorrect data can occur under certain rare conditions involving command-based invalidation.

In command-based invalidation, any data update command will call invalidations before the performExecute() method is called. Since DynaCache is multithreaded, it is possible that another data fetch command could potentially read data immediately after an update command finishes its invalidation calls, but before the update command commits its changes to the back-end database.

This is a problem. The fetch command would see the data that it has just read (which is actually stale) is not in the cache, and so it places it back in there. The scenario results in cache entries with stale data that do not get invalidated as intended.

To circumvent this problem, the delay-invalidations property is set in the cache policy. The delay-invalidations is used to delay command invalidations until after the performExecute() method. You use delay-invalidations at the cache-entry level in a policy for a command resource to delay all invalidations done by it.

Cache entry using the delay-invalidations property...

<cache-entry> 
      <class>command</class> 
      <name>UpdateCommand</name> 
      <cache-id> 
         <component id="userGroup" type="field" /> 
         <component id="getUserNumber" type="method" /> 
      </cache-id> 
      <invalidation>USER 
         <component id="userGroup" type="field" /> 
         <component id="getUserNumber" type="method" /> 
      </invalidation> 
      <invalidation>GROUP 
         <component id="userGroup" type="field" /> 
      </invalidation> 
      <property name="delay-invalidations">true</property> 
  </cache-entry>

In the example, invalidation IDs for both "USER" and "GROUP" basenames are created and called after UpdateCommand executes. If the delay-invalidations property is not set, the invalidation IDs are created and invalidations occur before the command executes.

+

Search Tips   |   Advanced Search