I cannot find it anywhere in Ehcache docs.
I am now using this code to create and configure my Cache:
def cacheConfig = new CacheConfiguration('stats', 1)
cacheConfig.timeToLiveSeconds = 2
def cache = new Cache(cacheConfig)
cache.initialise()
and to obtain data:
def cachedElement = cache.get('stats')
if (cachedElement != null && ! cachedElement.isExpired()) {
} else {
}
return cachedElement.value
I wrote this a while ago, but looking at it now, it seems that it was stupid to check Element.isExpired()- it is not necessary, is it? I mean, if an item has expired, then the cache should not return it - right?
So, I think I can remove this check - I just hope that a quick check will be done here.
Thank!
source
share