[Java programming language only]

Configuring object or servlet dynamic cache instances

WebSphere® Application Server allows you to configure multiple object or servlet dynamic cache instances in addition to the default instance. Use this procedure to configure additional object or servlet cache instances.

Before you begin

About this task

There are two types of cache instances you can create with this procedure, object cache instances and servlet cache instances. An object cache instance is a location in addition to the default shared dynamic cache where Java 2 Platform, Enterprise Edition (J2EE) applications can store, distribute, and share objects. After configuring object cache instances, you can use the DistributedMap or DistributedObjectCache interfaces in the com.ibm.websphere.cache package to programmatically access your cache instances. See the Additional Application Programming Interfaces (APIs) for more information about the DistributedMap or DistributedObjectCache interfaces. Servlet cache instances are locations in addition to the default dynamic cache where dynamic cache can store, distribute, and share the output and the side effects of an invoked servlet. By configuring a servlet cache instance, your applications have greater flexibility and better tuning of cache resources. The Java Naming and Directory Interface (JNDI) name that is specified for the cache instance in the administrative console maps to the cache instance element in the cachespec.xml configuration file. Any <cache-entry> elements that are specified within a <cache-instance> element are created in that specific cache instance. Any <cache-entry> elements that are specified outside of a <cache-instance> element are stored in the default dynamic cache instance. See Cache instances for more information about object and servlet type cache instances.
The steps in this procedure are for Version 8.0 of the WebSphere Application Server administrative console. This information may vary slightly depending on the version of WebSphere Application Server you are using.
Note:
  • WebSphere eXtreme Scale Version 8.6 is not supported on versions of WebSphere Application Server prior to Version 7.0.

Procedure

  • To configure an object or servlet cache with the WebSphere Application Server administrative console, use the following steps:
    1. Start the WebSphere Application Server administrative console.
    2. In the top menu, click Resources > Cache instances > Object cache instances.
    3. In the Object cache instances area, select the type of cache instance you want to create.
      This can be either an object cache instance or a servlet cache instance.
    4. Specify the scope of the cache instance. Specify a scope of cell to make the cache instance available to all the servers that are in the cell. Node scope make the cache instance available to all servers in a node. Server scope makes the cache instance available to the selected server only. If necessary, you can mix the scopes.
    5. Click Apply and save the scope.
    6. Click New and define an object cache instance.
    7. From the Cache provider drop-down list, select WebSphere eXtreme Scale.
      Note: If you do not see WebSphere eXtreme Scale as a dynamic cache provider, then your WebSphere Application Server profile has not been augmented for WebSphere eXtreme Scale. For more information, see Creating and augmenting profiles for WebSphere eXtreme Scale.
    8. Specify a JNDI name for the dynamic cache instance. For object caches, this name will be used when the cache is looked up. For servlet caches, this is the name attribute that is specified in the <cache-instance> element in the cachespec.xml file.
    9. Specify a JNDI name for the dynamic cache object.
    10. If you want to change the cache size, specify it in the Cache size box.
      The cache size value specifies the maximum number of entries allowed in each partition within a WebSphere eXtreme Scale grid for this dynamic cache instance. The default is 2000 entries in each partition.
    11. Select the Enable cache replication box.
      Enabling this checkbox means that cached data is stored remotely in the grid and not locally. This box must be selected when using WebSphere eXtreme Scale as the cache provider.
    12. Click Apply or OK and save the configuration.
  • To configure an object or servlet cache using the cacheinstances.properties file, use the following steps:
    1. Create a cacheinstances.properties file.
      See Cache instances properties file for required contents.
    2. Place the cacheinstances.properties file in either your application server or application class path. For example, you can use your application WAR (Web application archive) file, WEB-INF\classes directory or create a server_root\classes directory and place the file there.

What to do next

By default, each dynamic cache instance that is configured on WebSphere Application Server corresponds to a dynamic cache data grid that has the same name as the JNDI name of the cache instance. Also, by default, the data for that cache instance is stored in a dynamic map within that dynamic cache data grid, and the suffix for that dynamic map name also corresponds to the JNDI name of the cache instance. For example, if you were to configure a cache instance on WebSphere Application Server with a JNDI name of cache1, then a dynamic cache data grid is created with the name cache1. Inside data grid cache1, a dynamic map named IBM_DC_PARTIONED_cache1 is created to store the data.

In most cases, this configuration does not need to be changed. However, in some circumstances, you might want multiple cache instances, with different JNDI names, to map to different dynamic maps within the same data grid instance. In other circumstances, you might want multiple cache instances, with the same JNDI name, to map to different dynamic cache data grid instances or different dynamic map instances within the same dynamic cache data grid. For example, if you have an application that uses the default dynamic cache instance (baseCache), you might want to use the same data grid for both of your test level and production level environments, while you keep the cached data in separate data grids or separate dynamic maps within the same data grid.

You can set the following custom properties on the cache instances to control this configuration:
Tip: These properties can be especially useful when you use the default dynamic cache instance (baseCache), since the JNDI name for the cache is automatically set to baseCache and cannot be changed.
com.ibm.websphere.xs.dynacache.grid_name
Use this custom property to specify the name of the dynamic cache data grid instance to which a dynamic cache instance corresponds.
com.ibm.websphere.xs.dynacache.cache_name
Use this custom property to specify the name to be used, in place of the JNDI name, for both the dynamic cache data grid name and the dynamic map inside that data grid. If the com.ibm.websphere.xs.dynacache.grid_name custom property is also set, then the value of this property applies only to the dynamic map name.
For information about how to set these properties, see Customizing a dynamic cache instance with custom properties.