Make EHCache items expiring items that weren’t available in a specific way

I am trying to get EHCache to mark cache items as expired if they were not available in a certain way for a certain period of time.

I have an automatic cache update that should update items in the cache without updating the last access time. He works on a regular schedule. However, if the user requests something from the cache through the application, the last access time should be updated. Items must expire and be removed from the cache after a week of user inactivity.

Does EHCache have something already in place that could solve this problem? I see the putQuiet and getQuiet methods , but I don’t see an explicit mention of them without updating the last access time. Also, is there any real difference between the timeToLiveSeconds and timeToIdleSeconds parameters?

Thanks Mike

+4
source share
1 answer
timeToIdleSeconds: Sets the time to idle for an element before it expires. ie The maximum amount of time between accesses before an element expires Is only used if the element is not eternal. Optional attribute. A value of 0 means that an Element can idle for infinity. The default value is 0. timeToLiveSeconds: Sets the time to live for an element before it expires. ie The maximum time between creation time and when an element expires. Is only used if the element is not eternal. Optional attribute. A value of 0 means that and Element can live for infinity. The default value is 0. 

other attributes are referenced by ehcache.xml, which comes with the ehcache package. you can create your cache using Cache construtor with parameters, then the cache will manage this on its own

+2
source

All Articles