【问题标题】:ehcache flushing to disk on every writeehcache 在每次写入时刷新到磁盘
【发布时间】:2015-10-20 15:26:48
【问题描述】:

我在我的服务器上使用 ehcache 作为热缓存。我希望它完全在内存中,并且只写入磁盘以保持持久性。从应用程序重新启动时重新加载。

我看到 ehcache 几乎在每个缓存上都写入磁盘。这是文档所说的

Operation of a Cache where overflowToDisk is false and diskPersistent is true

In this configuration case, the disk will be written on flush or shutdown.
The next time the cache is started, the disk store will initialise but will not permit overflow from the
MemoryStore. In all other respects it acts like a normal disk store.

但是,当我检查 /mnt/ehcache 时,我发现它在每次放置时都被写入。发生这种情况的任何原因?

这是我的缓存配置。

    <diskStore path="/mnt/ehcache/" />

    <cache 
    name="feedLocalCache" 
    maxEntriesLocalHeap="2000000"
    eternal="false"
    timeToLiveSeconds="1800"
    timeToIdleSeconds="0"         
    diskPersistent="true"
    overflowToDisk="false"
    memoryStoreEvictionPolicy="LFU" >
    <bootstrapCacheLoaderFactory class="net.sf.ehcache.store.DiskStoreBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true"/>

【问题讨论】:

    标签: java ehcache


    【解决方案1】:

    归咎于文档过时。

    由于 Ehcache 2.6 是最低层,也称为权限 - 在您的情况下为磁盘 - 始终包含所有映射。这是为了提高延迟的可预测性。

    所以你看到的是预期的行为。请注意,磁盘写入是异步的,因此不会影响执行 put 的线程 - 除非您写入太多以至于写入队列达到其最大大小。

    【讨论】:

    • 我的服务器负载很大。我会说我每秒执行接近 2k 次放置和每秒至少 5k 次读取。知道如何提高我的表现吗?因为当我进行一些分析时,put 和 get 被显示为热点之一。
    猜你喜欢
    • 1970-01-01
    • 2019-09-22
    • 2011-01-28
    • 2010-09-15
    • 2010-09-10
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多