【问题标题】:Write cached data of Ehcache to local file(disk) after server start and on restart data should be picked up from file(disk)服务器启动后将 Ehcache 的缓存数据写入本地文件(磁盘),重新启动时应从文件(磁盘)中提取数据
【发布时间】:2018-12-10 09:40:37
【问题描述】:

我在服务器启动时创建一个缓存(服务器启动每次需要 10 分钟)。目前我正在使用内存缓存(Ehcache)。现在我想建立一个机制,以便一旦数据被缓存我应该能够在几秒钟内启动服务器。类似于将缓存的持久副本写入文件并在重新启动时它应该从该文件中获取缓存。 [如果问题不清楚,请告诉我。]。我期待 java 中的解决方案。

<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd" >

<cache alias="testData" >

    <key-type>java.lang.String</key-type>
    <value-type>java.lang.String</value-type>
    <resources>
        <heap unit="entries">5000</heap>
        <offheap unit="MB">50</offheap>

    </resources>
</cache></config>

我正在使用上面的 xml。你(@vivekg)可以建议对这个 xml 进行更改吗?

【问题讨论】:

标签: java ehcache ehcache-3


【解决方案1】:

Ehcache 的磁盘层应该能够在这种情况下提供帮助。请注意,如果这些不是永不过期的参考数据,您将必须解决过时数据的问题。

查看the documentation,了解如何设置。

【讨论】:

  • 知道了。我们可以使用 ehcache.xml 解决同样的问题吗?
猜你喜欢
  • 2018-11-16
  • 2021-03-29
  • 2020-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-20
  • 1970-01-01
  • 2014-06-12
相关资源
最近更新 更多