Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
demonstrates fetching TTL values from EhCache using Grails Console Plugin
import grails.plugin.cache.ehcache.GrailsEhcacheCache;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.joda.time.*
GrailsEhcacheCache gC = ctx.grailsCacheManager.getCache('customerAdvisors')
Ehcache nC = gC.getNativeCache()
Element e = nC.get(0) //0 is the key if the method has no parameters.
println new DateTime(new Date(e.getExpirationTime()))
println new DateTime(new Date(e.getCreationTime()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment