0
votes

I am trying to configure Ehcache with a disk persistence that does not initialize the disk cache until the heap is full. Is that possible?

Right now as soon as I initialize my cache I see that the disk cache is created on the file system. Most cases my heap will be big enough to contain my data, so thus I would not want to create a disk store that will not be used. I am using ehcache on a phone where disk space is an issue. And I could potentially need a 1GB disk persistence and so now it creates this large file everytime I initialize my cache.

1
"Is that possible?" -- While I don't know for sure, my guess would very much be "no". There's no standard Java API to check whether the heap is full, and I think that any Hotspot- or Dalvik-specific API would be fragile enough that noone would want to use it seriously. - Dolda2000
I don't mean the entire heap is full, I mean just the portion on the heap I allocated for my cache with newResourcePoolsBuilder().heap(50, MemoryUnit.MB) - user1159819

1 Answers

1
votes

While specific configuration on old versions will behave that way, since Ehcache 2.6.x the tiering model no longer works using overflow.

When you assign a disk tier, it becomes the authority and it will always contain all mappings, from the very first one inserted into the cache.