首页 文章

ehcache在每次写入时刷新到磁盘

提问于
浏览
0

我在我的服务器上使用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"/>

1 回答

  • 2

    归咎于文档过时 .

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

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

相关问题