To control the size of the near cache, configure a client-side override that enables an evictor on the client.
<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
xmlns="http://ibm.com/ws/objectgrid/config">
<objectGrids>
<objectGrid name="CompanyGrid">
<backingMap name="Customer" nearCacheEnabled="true"
pluginCollectionRef="customerPlugins" />
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="customerPlugins">
<!-- Limit the near cache size to 53*1000=53,000 entries using a least recently used algorithm -->
<bean id="Evictor" className="com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor">
<property name="numberOfLRUQueues" type="int" value="53" description="set number of LRU queues" />
<property name="maxSize" type="int" value="1000" description="set max size for each LRU queue" />
</backingMapPluginCollection>
</backingMapPluginCollections>
</objectGridConfig>
Use the following code snippet to programmatically configure an LRU evictor for the near cache:
ObjectGridConfiguration companyGridConfig = ObjectGridConfigFactory
.createObjectGridConfiguration("CompanyGrid");
BackingMapConfiguration customerMapConfig = ObjectGridConfigFactory
.createBackingMapConfiguration("Customer");
Plugin evictorPlugin = ObjectGridConfigFactory.createPlugin(PluginType.EVICTOR,
"com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor");
ConfigProperty numQueues=ObjectGridConfigFactory.createConfigProperty(ConfigPropertyType.INT_PRIM,
"numberOfLRUQueues", "53");
evictorPlugin.addConfigProperty(numQueues);
ConfigProperty maxSize=ObjectGridConfigFactory.createConfigProperty(ConfigPropertyType.INT_PRIM,
"maxSize", "1000");
evictorPlugin.addConfigProperty(maxSize);
customerMapConfig.addPlugin(evictorPlugin);
companyGridConfig.addBackingMapConfiguration(customerMapConfig);
ClientClusterContext client = ogManager.connect(catalogServerEndpoints, null, null);
ObjectGrid companyGrid = ogManager.getObjectGrid(client, objectGridName,companyGridConfig);