Chapter 6. Cache Modes

Red Hat JBoss Data Grid provides two modes:
  • Local mode is the only non-clustered cache mode offered in JBoss Data Grid. In local mode, JBoss Data Grid operates as a simple single-node in-memory data cache. Local mode is most effective when scalability and failover are not required and provides high performance in comparison with clustered modes.
  • Clustered mode replicates state changes to a small subset of nodes. The subset size is sufficient for fault tolerance purposes but not large enough to hinder scalability. Before attempting to use clustered mode, it is important to first configure JGroups for a clustered configuration. For details about configuring JGroups, see Section 26.2, “Configure JGroups (Library Mode)”

6.1. About Cache Containers

Cache containers are used in Red Hat JBoss Data Grid's Remote Client-Server mode as a starting point for a cache. The cache-container element acts as a parent of one or more (local or clustered) caches. To add clustered caches to the container, transport must be defined.
The following procedure demonstrates a sample cache container configuration:

Procedure 6.1. How to Configure the Cache Container

  1. Specify the Cache Container

    The cache-container element specifies information about the cache container using the following parameters:
    <subsystem xmlns="urn:infinispan:server:core:6.1" 
    	   default-cache-container="default">
    1. Set the Cache Container Name

      The name parameter defines the name of the cache container.
      <subsystem xmlns="urn:infinispan:server:core:6.1" 
      	   default-cache-container="default">
      	<cache-container name="default" />
    2. Specify the Default Cache

      The default-cache parameter defines the name of the default cache used with the cache container.
      <subsystem xmlns="urn:infinispan:server:core:6.1" 
      	   default-cache-container="default">
      	<cache-container name="default" 
      			 default-cache="default" />
    3. Enable/Disable Statistics

      The statistics attribute is optional and is true by default. Statistics are useful in monitoring JBoss Data Grid via JMX or JBoss Operations Network, however they adversely affect performance. Disable this attribute by setting it to false if it is not required.
      <subsystem xmlns="urn:infinispan:server:core:6.1" 
      	   default-cache-container="default">
      	<cache-container name="default" 
      			 default-cache="default" 
      			 statistics="true"/>
    4. Define the Listener Executor

      The listener-executor defines the executor used for asynchronous cache listener notifications.
      <subsystem xmlns="urn:infinispan:server:core:6.1" 
      	   default-cache-container="default">
      	<cache-container name="default" 
      			 default-cache="default"
      			 statistics="true"
      			 listener-executor="infinispan-listener" />
    5. Set the Cache Container Start Mode

      The start parameter indicates when the cache container starts, i.e. whether it will start lazily when requested or "eagerly" when the server starts up. Valid values for this parameter are EAGER and LAZY.
      <subsystem xmlns="urn:infinispan:server:core:6.1" 
      	   default-cache-container="default">
      	<cache-container name="default" 
      			 default-cache="default" 
      			 statistics="true"
      			 listener-executor="infinispan-listener" 
      			 start="EAGER">
  2. Per-cache Statistics

    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.
    <subsystem xmlns="urn:infinispan:server:core:6.1" 
    	   default-cache-container="default">
    	<cache-container name="default" 
    			 default-cache="default" 
    			 statistics="true"
    			 listener-executor="infinispan-listener" 
    			 start="EAGER">
    		<local-cache name="default"
    		   statistics="true">
    			...
    		</local-cache>
    	</cache-container>
    </subsystem>