3

overflowToDisk: Sets whether elements can overflow to disk when the memory store has reached the maxInMemory limit.

As my understanding, it will not write to disk if the memoryStoresSize doesn't reach the maxElementsInMemory. But it seems not like this.

I have a simple cache as following:

<cache name="cache" maxEntriesLocalHeap="100000" eternal="true"  
 overflowToDisk="true" statistics = "true">
    <terracotta clustered="false"/>
</cache>

And I printed the statistics when getting values from cache.

System.out.println("memory size:" + cache.getMemoryStoreSize());
System.out.println("disk size:" + cache.getDiskStoreSize());

But the output shows the disk size is not 0 even if the memory size is very less than maxElementsInMemory.

memory size:2
disk size:186
memory size:2
disk size:186
memory size:3
disk size:186
memory size:3
disk size:186

Even the memory size is less than the disk size. How could this happen? or how can I configure it to work as expected?

Thanks.

2
  • This could happen after application restart and there was disk cache already.
    – Chandra
    May 25, 2012 at 7:34
  • @Chandra but the cache is not persistent... I cleaned the disk file and restarted the application. It's still the same result..
    – Saber
    May 25, 2012 at 9:26

1 Answer 1

1

Ehcache has changed its storage model since version 2.6 - see this answer for details.

What you are seeing is thus perfectly normal.

Legacy configuration options have not been renamed for compatibility reason - although I agree that the description should have been. Have a look at the latest documentation on disk backed caches for recommended way of configuring.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.