Chapter 7. Set Up Invalidation Mode

7.1. About Invalidation Mode

Invalidation is a clustered mode that does not share any data, but instead removes potentially obsolete data from remote caches. Using this cache mode requires another, more permanent store for the data such as a database.

Red Hat JBoss Data Grid, in such a situation, is used as an optimization for a system that performs many read operations and prevents database usage each time a state is needed.

When invalidation mode is in use, data changes in a cache prompts other caches in the cluster to evict their outdated data from memory.

7.2. Configure Invalidation Mode

Invalidation mode is a clustered mode in Red Hat JBoss Data Grid. Invalidation mode can be added to any cache container, in both Library Mode and Remote Client-Server Mode, using the following procedure:

The invalidation-cache Element

<cache-container name="local"
     		 default-cache="default"
     		 statistics="true">
	<invalidation-cache name="default"
			    statistics="true">
			<!-- Additional configuration information here -->
	</invalidation-cache>
</cache-container>

The invalidation-cache element configures settings for the distributed cache using the following parameters:

  1. The name parameter provides a unique identifier for the cache.
  2. If statistics are enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting the statistics attribute to false.
Important

JGroups must be appropriately configured for clustered mode before attempting to load this configuration.

For details about the cache-container see the appropriate chapter.

7.3. Synchronous/Asynchronous Invalidation

In Red Hat JBoss Data Grid’s Library mode, invalidation operates either asynchronously or synchronously.

  • Synchronous invalidation blocks the thread until all caches in the cluster have received invalidation messages and evicted the obsolete data.
  • Asynchronous invalidation operates in a fire-and-forget mode that allows invalidation messages to be broadcast without blocking a thread to wait for responses.

7.4. The L1 Cache and Invalidation

An invalidation message is generated each time a key is updated. This message is multicast to each node that contains data that corresponds to current L1 cache entries. The invalidation message ensures that each of these nodes marks the relevant entry as invalidated.