15.3. Cache Containers

Cache Containers
A cache container is repository for the caches used by a subsystem. For Infinispan default cache containers are defined in the configuration xml files (standalone-ha.xml, standalone-full-ha.xml, domain.xml). One cache is defined as the default cache, which is the cache that will be used for clustering.

Example 15.1. Cache container definitions from standalone-ha.xml configuration file

<subsystem xmlns="urn:jboss:domain:infinispan:1.5">
       <cache-container name="singleton" aliases="cluster ha-partition" default-cache="default">
          <transport lock-timeout="60000"/>
          <replicated-cache name="default" mode="SYNC" batching="true">
             <locking isolation="REPEATABLE_READ"/>
          </replicated-cache>
       </cache-container>
       <cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
        <transport lock-timeout="60000"/>
        <replicated-cache name="repl" mode="ASYNC" batching="true">
          <file-store/>
        </replicated-cache>
        <replicated-cache name="sso" mode="SYNC" batching="true"/>
          <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
           <file-store/>
          </distributed-cache>
        </cache-container>
Note the default cache defined in each cache container. In this example, in the web cache container, the repl cache is defined as the default. The repl cache will therefore be used to when clustering web sessions.
The cache containers and cache attributes can be configured using the Management Console or CLI commands, but it is not advisable to change the names of either cache containers or caches.
Configure Cache Containers
Cache containers for Infinispan can be configured using the CLI or the Management Console.

Procedure 15.1. Configure the Infinispan Cache Containers in the Management Console

  1. Select the Configuration tab from the top of the screen.
  2. For Domain mode only, select either ha or full-ha from the drop down menu at top left.
  3. Expand the Subsystems menu, then expand the Infinispan menu. Select Cache Containers.
  4. Select a cache container from the Cache Containers table.
  5. Add, Remove or Set Default Cache Container

    1. To create a new cache container, click Add from the Cache Containers table.
    2. To remove a cache container, select the cache container in the Cache Containers table. Click Remove and click OK to confirm.
    3. To set a cache container as default, click Set Default, enter a cache container name from the drop down list, click Save to confirm.
  6. To add or update the attributes of a cache container, select the cache container in the Cache Containers table. Select one from the Attributes, Transport and Aliases tabs in the Details area of the screen, and click Edit. For help about the content of the Attributes, Transport and Aliases tabs, click Need Help?.

Procedure 15.2. Configure the Infinispan Cache Containers in the Management CLI

  1. To get a list of configurable attributes, enter the following CLI command:
    /profile=profile name/subsystem=infinispan/cache-container=container name:read-resource
  2. You can use the Management CLI to add, remove and update cache containers. Before issuing any commands to do with cache containers, ensure that you use the correct profile in the Management CLI command.
    1. Add a Cache Container

      To add a cache container base your command on the following example:
      /profile=profile-name/subsystem=infinispan/cache-container="cache container name":add
    2. Remove a Cache Container

      To remove a cache container base your command on the following example:
      /profile=profile-name/subsystem=infinispan/cache-container="cache container name":remove
    3. Update Cache Container attributes

      Use the write-attribute operation to write a new value to an attribute. You can use tab completion to help complete the command string as you type, as well as to expose the available attributes. The following example updates statistics-enabled to true.
      /profile=profile name/subsystem=infinispan/cache-container=cache container name:write-attribute(name=statistics-enabled,value=true)