Reputation: 567
I'm using ehcache as a hot cache on my server. I want it to be completely in memory and only write to disk for persistence. To load back from when the application restarts.
I'm seeing that ehcache is writing to disk on almost every cache put. Here is what the documentation says
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.
However when I check /mnt/ehcache I see that it's being written to on every put. Any reason why it's happening?
Here's my cache config.
<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"/>
Upvotes: 0
Views: 1543
Reputation: 14500
Blame it on the documentation to be outdated.
Since Ehcache 2.6 the lowest tier, also called authority - disk in your case - always contains all the mappings. This is to improve predictability of the latency.
So what you are seeing is the expected behaviour. Note that the disk writing is asynchronous and so does not impact your thread doing the put - unless you write so much that the write queue reaches its maximum size.
Upvotes: 2