[Java programming language only]

Configuring a near cache for the dynamic cache

[Version 8.6 and later]You can enable near cache in your dynamic cache provider so that an independent data grid exists on your dynamic cache provider, serving as a fast cache for the remote, server-side cache.

About this task

Modify the backingMap of the objectgrid.xml file to enable near cache in dynamic cache.

The dynacache-nearcache-objectgrid.xml file is included in both the client and server installations. You can copy or modify this file as needed.  This file is already configured as described in the following instructions. In most cases you can use this file without significant changes.   The dynacache-nearcache-objectgrid.xml file is in thewas_root/optionalLibraries/ObjectGrid/dynacache/etc or wxs_home/ObjectGrid/dynacache/etc directory.

Procedure

Add the following properties to the backingMap of the objectgrid.xml file to enable near cache on your dynamic cache provider:
A near cache for a dynamic cache must have the nearCacheEnabled, nearCacheInvalidationEnabled, and nearCacheLastAccessTTLSyncEnabled properties that are set to true; for example:
<backingMap name="IBM_DC_PARTITIONED_.*" template="true" readOnly="false"  
< pluginCollectionRef="all" preloadMode="false" nearCacheEnabled="true" 
nearCacheInvalidationEnabled="true" nearCacheLastAccessTTLSyncEnabled= "true" 
lockStrategy="OPTIMISTIC" 
copyMode="COPY_ON_READ_AND_COMMIT" ttlEvictorType="NONE" nullValuesSupported="false" />
Each of the attributes on the backingMap element have the following definitions:
[Version 8.6 and later]nearCacheEnabled
[Version 8.6 and later]Set the value to true to enable the client local cache. To use a near cache, the lockStrategy attribute must be set to NONE or OPTIMISTIC. If the lockStrategy attribute must is set to NONE or OPTIMISTIC, the nearCacheEnabled property is set to true.

Default: true (Optional)

[Version 8.6 and later]nearCacheInvalidationEnabled
[Version 8.6 and later]Set the value to true to enable the removal of stale data from the near cache as quickly as possible. Any update , deletion, or invalidation operation against the data grid triggers an asynchronous invalidation in the near cache. Because the invalidation is asynchronous, client applications might access stale data for a short time period after an update has occurred before the stale value is removed from the near cache. To use near cache invalidation, the lockStrategy attribute must be set to NONE or OPTIMISTIC. To enable a near cache for a dynamic cache instance, this value must be set to true.

Default: false (Optional)

[Version 8.6 and later]nearCacheLastAccessTTLSyncEnabled
[Version 8.6 and later]Set the value to true to enable time-to-live (TTL) information to be synchronized with the remote data grid. To enable a near cache for a dynamic cache instance, this value must be set to true. If you are not using a dynamic cache near cache, you must enable the LAST_ACCESS_TIME TTL evictor type when you enable this property.
[Version 8.6.0.4 and later]Attention: Setting the value to true for a dynamic cache near cache is now optional.

Default: false (Optional)

What to do next

By default, the maximum size of the dynamic near cache corresponds to the maximum number of entries for a single partition in the remote dynamic cache data grid. A least recently used (LRU) eviction algorithm is used to maintain this size. To further control the size of the near cache, you can take the following action:
  • Configure the com.ibm.websphere.xs.dynacache.near_cache_size custom property to specify the maximum number of cache entries that are allowed in the near cache. For more information, see Dynamic cache custom properties.