Jboss infinispan钝化能否与基于内存的逐出一起使用?

Jboss infinispan钝化能否与基于内存的逐出一起使用?,jboss,infinispan,Jboss,Infinispan,使用 JBoss 7.1.0 EAP Infinispan 8.2.8.Final-redhat-1 是否可以在infinispan中使用钝化和基于内存的逐出 当我尝试使用此配置时: ConfigurationBuilder config = new ConfigurationBuilder(); config.clustering().cacheMode(CacheMode.DIST_SYNC); config.eviction() .type(EvictionType.MEMORY)

使用

JBoss 7.1.0 EAP Infinispan 8.2.8.Final-redhat-1 是否可以在infinispan中使用钝化和基于内存的逐出

当我尝试使用此配置时:

ConfigurationBuilder config = new ConfigurationBuilder();
config.clustering().cacheMode(CacheMode.DIST_SYNC);
config.eviction()
    .type(EvictionType.MEMORY) 
    .size(heapAllocationForCache);
config.persistence().passivation(true)
        .addSingleFileStore()
        .location("/path/to/cache-dir")
        .purgeOnStartup(true);
尝试此配置时,出现以下错误:

2019-10-30 11:28:59信息[]逐出配置生成器:114-ISPN000152:未选择逐出策略的情况下配置钝化。只有手动逐出的实体才会被钝化

以下是验证逻辑:

if (!strategy.isEnabled()) {
   if (maxEntries > 0) {
      strategy(EvictionStrategy.LIRS);
      log.debugf("Max entries configured (%d) without eviction strategy. Eviction strategy overriden to %s", maxEntries, strategy);
   } else if (getBuilder().persistence().passivation() && strategy != EvictionStrategy.MANUAL) {
      log.passivationWithoutEviction(); // <--------- this line is where the warning comes from
   }
}

你应该能够。但问题是,在8.2中,默认策略是NONE[1]。将策略设置为LIRS或LRU可以解决您的问题。Infinispan的更新版本不再需要此设置,除非您希望将其设置为手动逐出策略

config.eviction()
   .type(EvictionType.MEMORY)
   .strategy(EvictionStrategy.LRU) 
   .size(heapAllocationForCache);

[1]

当您使用EAP时,我不会在EAP内部使用Infinispan位,因为这不用于应用程序缓存-您也不能更新版本,因为这不受支持。 最好的方法是使用RHDG作为受支持的产品,或者如果您不能使用最新的Infinispan版本来拥有完整的功能集和最新的修复程序,则使用RHDG。 另外,对于9.xyuo,可以使用堆外内存,这通常会提供更好的性能


有关更多详细信息,请参阅本文

maxEntries或size不可能是它对我来说没有意义,因为我想清除内存。。不算驱逐。它看起来像是9.x中后来修复的一个bug。我说的对吗?只要您正在配置executionType.MEMORY,它们就共享相同的名称。size参数是执行execution时的近似字节数。
config.eviction()
   .type(EvictionType.MEMORY)
   .strategy(EvictionStrategy.LRU) 
   .size(heapAllocationForCache);