Question

The Ehcache docs (https://www.ehcache.org/documentation/2.8/configuration/cache-size.html) describe maxEntriesLocalHeap as:

The maximum number of cache entries or bytes a cache can use in local heap memory, or, when set at the CacheManager level (maxBytesLocalHeap only), a local pool available to all caches under that CacheManager. This setting is required for every cache or at the CacheManager level.

Does this mean that for this configuration :

<cache
        name="myCache"
        maxEntriesLocalHeap="5000"
        eternal="false"
        overflowToDisk="false"
        timeToLiveSeconds="10000"
        memoryStoreEvictionPolicy="FIFO" />

The maximum number of objects that can be added to the cache is 5000. These objects can contain multiple child objects but just the top level parent object is added as an entry. So under the hood the amount of maxEntriesLocalHeap objects could grow to 15000 (at this point the oldest object is swapped out as new objects are added) if each object has a reference to two other objects. Is this correct ?

Was it helpful?

Solution

Yes.

The maxEntriesLocalHeap enforcement is only going to count the number of key/value pairs you store in the cache. It's up to you as the user to have a good understanding of the heap overhead of retaining each of these entries, and ensuring that your configured Java heap can cope with this load.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top