代码之家  ›  专栏  ›  技术社区  ›  chrismarx

Ehcache diskstore在应用程序重新启动期间被删除

  •  6
  • chrismarx  · 技术社区  · 16 年前

    我有一个ehcache设置,它工作得很好,只是每次我重新启动应用程序/服务器(TcServer/Tomcat上的Spring应用程序)时,持久的diskstore数据都会被删除。使用持久性diskstore的全部目的是能够在应用程序重新启动时持久化缓存。

    <?xml version="1.0" encoding="UTF-8"?><ehcache><diskStore path="java.io.tmpdir/ehcache"/><cache name="clusterCache"
      maxElementsInMemory="1"
      maxElementsOnDisk="50"
      eternal="true"
      overflowToDisk="true"
      diskPersistent="true" 
      memoryStoreEvictionPolicy="LFU"/></ehcache>
    

    你知道为什么会这样吗?

    1 回复  |  直到 16 年前
        1
  •  4
  •   ig0774    16 年前

    作为 documentation notes ,除非缓存通过VM shutdown钩子或(因为它在servlet容器中)它提供的servlet上下文侦听器正确关闭,否则Ehcache不会写入它要从磁盘还原的索引文件。看到了吗 Ehcache documentation on shutting down for details

    <listener>
          <listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
    </listener>