I'v useing LruEvictionPolicyFactory in my CacheConfiguration like blow
CacheConfiguration<K, V> cacheCfg = new CacheConfiguration<>();
cacheCfg.setDataRegionName("ds_name");
cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
cacheCfg.setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
cacheCfg.setEvictionPolicyFactory(new LruEvictionPolicyFactory<>(200000));
and I use DataRegionConfig like this
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="name" value="ds_name"/>
<property name="initialSize" value="#{512L * 1024 * 1024}"/>
<property name="maxSize" value="#{3 * 1024L * 1024 * 1024}"/>
<property name="pageEvictionMode" value="RANDOM_LRU"/>
<property name="evictionThreshold" value="0.9"/>
<property name="metricsEnabled" value="true"/>
<property name="persistenceEnabled" value="false"/>
</bean>
but I can see far more than 2000000 records in my cache, for some times, i can see 800000 records in the cache
how to control data size in my cache to avoid one cache using too many memories
Your data region configuration seems to be more or less correct according to this doc page. I would recommend using
RANDOM_2_LRUand configure a data region name to use it for the reference.In turn your
CacheConfigurationdoesn't contain the dataRegionName parameter. For example: