File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EhCache and the fly likes Ehcache TimeToLiveSecond and TimeToIdleSeconds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Caching » EhCache
Bookmark "Ehcache TimeToLiveSecond and TimeToIdleSeconds" Watch "Ehcache TimeToLiveSecond and TimeToIdleSeconds" New topic

Ehcache TimeToLiveSecond and TimeToIdleSeconds

Ganesh Shirsat
Ranch Hand

Joined: Jan 10, 2010
Posts: 33


1.What is the meaning of TimeToLiveSecond and TimeToIdleSecond.?
2. is they are removed, object from cache?

I tried one example.
TimeToLive = 1200
TimeToIdle = 15

I load the two object in cache first time.

i access the object after 30 second .
before accessing the object. I print the statistics of Cache and it was still show me a two object in cache.
but when i was actually access the object it was fetch from database instead of cache.

that's mean object are expired but they are still in cache still we access the object again or memory is overflow.

is the above paragraph right?

Thanks ,
Ganesh Shirsat

Yagnesh N Chawda

Joined: Dec 31, 2009
Posts: 2
I think we should not use it together. May be this is of some help :

Thanks And Regards,
Yagnesh Chawda.

Good planets are hard to find. Print less!
Save energy to keep your future bright !!
"Earth provides enough to satisfy every man's need,
but not every man's greed." - Mahatma Gandhi
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

timeToLiveSecond is the time in seconds from the point of creation in the cache till it expires (regardless of how frequently it is accessed in that time)

timeToIdleSeconds is the time in seconds before an object in the cache expires if it is not accessed.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Ehcache TimeToLiveSecond and TimeToIdleSeconds
It's not a secret anymore!