Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to differentiate between time to live and time to idle in ehcache

Tags:

java

ehcache

The docs on ehache says:

timeToIdleSeconds: Sets the time to idle for an element before it expires. i.e. The maximum amount of time between accesses before an element expires  timeToLiveSeconds: Sets the time to live for an element before it expires. i.e. The maximum time between creation time and when an element expires. 

I understand timeToIdleSeconds

But does it means that after the creation & first access of a cache item, the timeToLiveSeconds is not applicable anymore ?

like image 440
Jacques René Mesrine Avatar asked Apr 06 '10 08:04

Jacques René Mesrine


People also ask

What is timeToLiveSeconds in ehcache?

timeToLiveSeconds – The maximum number of seconds an element can exist in the cache regardless of use. The element expires at this limit and will no longer be returned from the cache. The default value is 0, which means no TTL eviction takes place (infinite lifetime).

What is timeToLiveSeconds?

timeToLiveSeconds(TTL) : Is the time in seconds from the point of creation in the cache till it expires. i.e. the maximum time between creation time and when an element expires. The maximum number of seconds an element can exist in the cache regardless of use (regardless of how frequently it is accessed in that time).


1 Answers

timeToIdleSeconds enables cached object to be kept in as long as it is requested in periods shorter than timeToIdleSeconds. timeToLiveSeconds will make the cached object be invalidated after that many seconds regardless of how many times or when it was requested.

Let's say that timeToIdleSeconds = 3. Then the object will be invalidated if it hasn't been requested for 4 seconds.

If timeToLiveSeconds = 90, then the object will be removed from cache after 90 seconds, even if it has been requested few milliseconds in the 90th second of its short life.

like image 81
Boris Pavlović Avatar answered Sep 19 '22 04:09

Boris Pavlović