Configuring the near cache

Clients can optionally have a local, in-line cache when eXtreme Scale is used in a distributed topology. This optional cache is called a near cache, an independent data grid on each client, serving as a cache for the remote, server-side cache. The near cache is enabled by default when locking is disabled, or is configured as optimistic, and cannot be used when configured as pessimistic.

About this task

A near cache is fast because it provides local in-memory access to a subset of the entire cached data set that is stored remotely.

To configure the near cache, you can edit the necessary settings in the ObjectGrid XML file for your container server. The settings in this file apply to all clients, unless you override the settings. You can override the nearCacheEnabled setting for the near cache with either XML or programmatic configuration.

Procedure

  1. Near cache is enabled if you are using default settings. To enable the near cache, you must set the lockStrategy attribute in the ObjectGrid descriptor XML file for the container servers to NONE or OPTIMISTIC. The default value is OPTIMISTIC. For more information about the lockStrategy attribute, see ObjectGrid descriptor XML file. Clients do not maintain a near cache when the locking setting is configured as PESSIMISTIC.
  2. [Version 8.5 only] To enable or disable the near cache, set the numberOfBuckets attribute in the ObjectGrid descriptor XML file.

    The near cache is enabled by default when the lockStrategy attribute in the ObjectGrid descriptor XML file is set to NONE or OPTIMISTIC. Clients do not maintain a near cache when the locking setting is configured as PESSIMISTIC. To disable the near cache, you must set the numberOfBuckets attribute to 0 in the client override ObjectGrid descriptor file.

    numberOfBuckets
    Deprecated feature Deprecated: This property has been deprecated. Use the nearCacheEnabled attribute to enable the near cache.
    The BackingMap instance uses a hash map for implementation. The numberOfBuckets attribute specifies the number of buckets for the BackingMap instance to use. If multiple entries exist in the BackingMap, more buckets lead to better performance because the risk of collisions is lower as the number of buckets increases. More buckets also lead to more concurrency. Specify a value of 0 to disable the near cache on a client. When you set the value to 0 for a client, set the value in the client override ObjectGrid XML descriptor file only. (Optional)
  3. Restart the container servers and clients. For more information, see Starting and stopping stand-alone servers and Configuring container servers in WebSphere Application Server.

Results

To check whether a near cache is enabled, run the BackingMap.isNearCacheEnabled() method in your client. You can also look for the CWOBJ1128I message in the log files on the client to see if the near cache is enabled.

What to do next

By default, the client-side near cache does not have a maximum size and out of memory errors in the client can occur. To control the size of the near cache, configure a client-side override that enables a time-to live (TTL) or least recently used (LRU) evictor on the client. For more information about configuring an evictor for the near cache, see Configuring an evictor for the near cache.