-
1. Re: eviction vs expiration
mlinhard Feb 26, 2012 5:25 AM (in response to mmm12)If the documentation entry https://docs.jboss.org/author/display/ISPN/Eviction doesn't help,
my understanding of eviction vs expiration is that both are means of cleaning the cache of unused entries and thus guarding the heap against OutOfMemory exceptions.
With eviction you set maximal number of entries you want to keep in the cache and if this limit is exceeded, some candidates are found to be removed according to a choosen eviction strategy (LRU, LIRS, etc...). Eviction can be setup to work with passivation (evicting to a cache store).
With expiration you set time criteria for entries, how long you want to keep them in cache. Either you set maximum lifespan of the entry - time it is allowed to stay in the cache or maximum idle time, time it's allowed to be untouched (no operation performed with given key).
-
2. Re: eviction vs expiration
mmm12 Feb 27, 2012 8:52 AM (in response to mlinhard)Thank you. I'm not sure how I missed it, was late at night.
However, the documentation doesn't answer all the questions.
For instance, it is not clear whether any eviction will happen at all if I leave the strategy at default (which seems to be NONE). If I do not have any expiration, should I disable the eviction threaed (set expirationWakeUpInterval to -1)?
-
3. Re: eviction vs expiration
mlinhard Feb 27, 2012 9:59 AM (in response to mmm12)(talking about newest master code now, since since https://issues.jboss.org/browse/ISPN-1869)
by default no eviction takes place i.e. when you don't specify <eviction> element in the xml.
if you specify maxEntries > 0 without the strategy: i.e. <eviction maxEntries="10000"/> the strategy defaults to LIRS and eviction takes place
if you specify maxEntries < 0 and define no or any strategy the eviction doesn't take place
if you specify maxEntries and strategy then both of your choices are honoured of course.
if you specify maxEntries = 0 (strange corner case) it seems to be allowed but depends on the strategy you define or not define: not defined defaults to NONE, and anything else than NONE means you'll have a cache that won't store any entries. I havent tried this.
-
4. Re: eviction vs expiration
mlinhard Feb 27, 2012 11:06 AM (in response to mmm12)About the eviction thread. If you're sure that you don't need expiration you could turn it off.
Btw expiration set in the xml config is a default expiration. You could explicitly set lifespan and maxIdle time of an entry when putting it via BasicCache.put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit);
when you don't start eviction thread then even explicit expiration probably won't work.
-
5. Re: eviction vs expiration
mlinhard Mar 2, 2012 10:12 AM (in response to mlinhard)The note about maxEntries = 0 case isn't correct, please see updated docs https://docs.jboss.org/author/display/ISPN/Eviction for details.