【问题标题】:Entries in cache are not evicted缓存中的条目不会被驱逐
【发布时间】:2019-01-25 15:16:57
【问题描述】:

我正在使用 Infinispan ( 9.4.5.Final ) 将数据本地存储在缓存中。

为此,我使用了这段代码(来自https://www.baeldung.com/infinispan

private Configuration passivatingConfiguration() {
return new ConfigurationBuilder()
  .memory().evictionType(EvictionType.COUNT).size(1)
  .persistence() 
  .passivation(true)    // activating passivation
  .addSingleFileStore() // in a single file
  .purgeOnStartup(true) // clean the file on startup
  .location(System.getProperty("java.io.tmpdir")) 
  .build();}

每次我在缓存中放入一些东西时,我都会打印它的大小:

cache.size()

缓存大小应该恒定为 1,但不能停止增加...

我正在尝试另一段代码:

private Configuration evictingConfiguration() {
return new ConfigurationBuilder()
  .memory().evictionType(EvictionType.COUNT).size(1)
  .build();}

而且...它正在工作...缓存的大小始终为 1。

我想修复内存。 有没有人遇到同样的问题?

【问题讨论】:

    标签: infinispan


    【解决方案1】:

    您已配置缓存存储。如果您注意到 javadoc 提到的大小,它在其调用中包含缓存加载器 https://docs.jboss.org/infinispan/10.0/apidocs/org/infinispan/Cache.html#size--

    如果您只想检索内存中条目的大小,请尝试以下操作:

    cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).size();
    

    【讨论】:

      猜你喜欢
      • 2013-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多