EHC ❯ Cache.applyDefaultsToElementWithoutLifespanSet doesnt set Element.cacheDefaultLifespan to false
-
Bug
-
Status: New
-
2 Major
-
Resolution:
-
ehcache-core
-
-
drb
-
Reporter: am_orcid
-
August 11, 2017
-
0
-
Watchers: 1
-
August 11, 2017
-
Description
I have TTL and TTI configured for my cache object, I also use the CopyOnWrite strategy.
So, anytime an element goes into the cache, the Cache.class uses the applyDefaultsToElementWithoutLifespanSet function to set the TTL and TTI configurations for the Element object; however, that function doesn’t set the cacheDefaultLifespan to false; then, as Im using the CopyOnWrite strategy, the ReadWriteSerializationCopyStrategy.duplicateElementWithNewValue is invoked to copy the element into a new one, however, that function checks if the Element.usesCacheDefaultLifespan is true, if it is, it set the default TTL and TTI to the new object (which is Integer.MIN_VALUE), which are different than the TTL and TTI set to the original Element.
This is causing that the cache elements don’t get expired, which cause us some problems since we have a cron that evicts expired elements.
The solution for this could be one of the followings:
1) On Cache.applyDefaultsToElementWithoutLifespanSet set the Element.cacheDefaultLifespan to false 2) On ReadWriteSerializationCopyStrategy.duplicateElementWithNewValue check if the source Element have any value different than the default for TTL or TTI and copy it over to the new Element.
Thanks