Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a performance hit with a maxElementsInMemory too big in ehcache config

Just wanted to know if there was a performance impact to setting a maxElementsInMemory much higher than what is actually used? For example, a max of 10,000 and using only 100.

ehcache.xml

<defaultCache
    eternal="false"
    overflowToDisk="false"
    maxElementsInMemory="10000"
    timeToIdleSeconds="7200"
    timeToLiveSeconds="0"/>

Context: I am using ehcache with hibernate and I want all records of a table (all entities) to be cached. From one customer to another, the number of records in that table varies so it is hard to set a precise max.

Thanks!

Marc

like image 838
Marc Avatar asked May 31 '12 18:05

Marc


1 Answers

No, there is none. This is just a max value. If your cache only holds 100 items, you will pay the cost of a map holding 100 elements. The upper limit has nothing to do here.

You can safely use much higher limit (underneath it is a simple ConcurrentHashMap) although it is hard to justify such a choice.

like image 80
Tomasz Nurkiewicz Avatar answered Oct 01 '22 09:10

Tomasz Nurkiewicz