Introduction
An Infinispan cache-container is a collection of cache stores.
This article describes how to create a cache-container together with a custom cache store via the Fusion Application Server's (FAS) JBoss admin console.
For detailed instructions and descriptions of all configuration items, please refer to the appropriate Infinispan documentation:
http://infinispan.org/docs/7.0.x/index.html
Creating a new cache-container
The following steps describe briefly how to create a new cache-container via the FAS's JBoss admin console.
1. Login to the JBoss admin console
2. Navigate to the 'Cache Containers' page:
Profiles > Profile:ha > Subsystems > Infinispan > Cache Containers
3. Click Add to create a new cache-container
- Give it a name e.g. my-cache-container
4. Click Save
The new cache-container will have been created and its details will have been written to the JBoss domain.xml file.
If required, its attributes (e.g. the start-mode of the cache-container) can be configured via the admin console or from within the domain.xml itself.
Note that if any attributes are changed from their defaults, a restart of FAS will be required for the changes to be applied.
Creating a new cache
A cache MUST exist within a cache-container.
This implies that the cache-container in which the new cache will reside must exist before the cache can be created.
The following steps show how to create a cache named MyCustomDataCache within the cache-container created earlier (my-cache-container).
1. Login to the JBoss admin console
2. Navigate to the 'Replicated Caches' page:
Profiles > ha > Subsystems > Infinispan > Replicated Caches
3. Click Add to create a new cache
- Set its name to: MyCustomDataCache
- Select the cache-container: my-cache-container
- Leave the clustered cache mode as the default: SYNC
4. Click Save
The new cache will have been created and its details will have been written to the JBoss domain.xml file.
Once the cache has been created, it can be configured. It is recommended that this is performed by editing the domain.xml.
Although a cache can be configured in a number of ways (as described in the Infinispan documentation linked above), the instructions below give an example of how configure it to simply do the following:
- Start the cache eagerly
- Ensure the cache is backed by a file, and
- Configure it such that it expires the data within it after a specified time
1. Navigate to the configuration directory containing the domain.xml - i.e <FAS_INSTALL_DIR>/domain/configuration/
2. Edit the domain.xml
3. Locate the newly created cache within the domain.xml by searching for the name of the cache: MyCustomDataCache
- The cache's definition will look like the following and will be part of the cache-container section named: my-cache-container
<replicated-cache name="MyCustomDataCache" mode="SYNC"/>
4. Update this cache definition as follows:
<replicated-cache name="UCCEAdapterDataCache" mode="SYNC" start="EAGER">
<expiration max-idle="600000" lifespan="2000"/>
<file-store shared="false" preload="true" passivation="false" fetch-state="true" purge="false" singleton="false"/>
</replicated-cache>
- NOTE: The example 'expiration' definition above has set the maximum idle time that a cache entry will be maintained in the cache to be 10 minutes. After this time, the entry will be expired. The definition has also set the lifespan of a cache entry to 2 seconds. After this time, it will be removed.
5. Save the changes to the domain.xml
6. Restart the Fusion Application Server (FAS) - e.g. service fas restart
Verifying the new cache
Upon restart of FAS, the newly created cache's configuration will be active.
Assuming the cache is backed by a file (as described above), a new folder will have been created named after the newly created cache i.e. MyCustomDataCache
The location of the cache's folder is:
<FAS_INSTALL_DIR>/domain/servers/appserver-xxxx/data/infinispan/my-container-cache/MyCustomDataCache
Comments
0 comments
Please sign in to leave a comment.