How can I make Ehcache never evict from a disk store?

I am trying to configure Ehcache (version 2.5) so that it never forgets the elements. Here is my initial attempt, but obviously Ehcache will try to protect me from itself by evicting if it runs out of keyspace.

Is there a way to configure Ehcache (free version) to really store items while the application is running? If Ehcache can lose items (without telling me!), Then I cannot use it for my own purposes. Note that I have higher heap orders that I use in this other example; I just set it up so that it starts writing to disk earlier.

+1
source share
1 answer

Using pinning: see http://ehcache.org/documentation/configuration/data-life#pinning-data and use cache binding in disk storage. Although I really don't understand what you expect from ehcache. If you want to avoid eviction at all costs, and maxBytesOnHeap is a bad idea. The whole point of specifying maxBytesOnHeap is to protect you from OOME'ing. Using Gigs of heap may make it more reasonable, I think ... but basically, when using DiskStore you (and ehcache) have to consider the key set that is stored in memory ... So with a maximum size maxBytesOnHeap> will help keep your hot set on the heap, next to the entire set of keys. Hope this helps!

+2
source

All Articles