13.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 13.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 theweb
cache container, therepl
cache is defined as the default. Therepl
cache will therefore be used 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 13.1. Configure the Infinispan Cache Containers in the Management Console
- Select thetab from the top of the screen.
- For Domain mode only, select eitheror from the drop down menu at top left.
- Expand themenu, then expand the menu. Select .
- Select a cache container from the Cache Containers table.
Add, Remove or Set Default Cache Container
- To create a new cache container, click Cache Containers table.from the
- To remove a cache container, select the cache container in the Cache Containers table. Click and click to confirm.
- To set a cache container as default, click, enter a cache container name from the drop down list, click to confirm.
- To add or update the attributes of a cache container, select the cache container in the Cache Containers table. Select one from the , and tabs in the Details area of the screen, and click . For help about the content of the , and tabs, click Need Help?.
Procedure 13.2. Configure the Infinispan Cache Containers in the Management CLI
- To get a list of configurable attributes, enter the following CLI command:
/profile=profile name/subsystem=infinispan/cache-container=container name:read-resource
- 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.
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
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
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)