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.

Saber
  • 71
  • 1
  • 6
  • This could happen after application restart and there was disk cache already. – Chandra May 25 '12 at 07: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 '12 at 09:26

1 Answers1

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.

Community
  • 1
  • 1
Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43