Hmmm, if what you're after is a cache entries age, as in the time that has passed since the entry was created, and last accessed time, Infinispan does not even make such information public. You might be able to hack to get this information but I wouldn't recommend doing that since it will tie you to the internals of Infinispan.
IMO, we should enable to query such information via JMX and then you could query it that way. This guarantees that the information is not only available to your use case, but any other one out there and you can access it in a standard way, without hacking it. I'll look into this possibility.
At the Hibernate level, I think it'd be good for Hibernate to expose this type of information via Statistics but I can't see it happening any time soon. I'll definitely pass the feedback on.
Actually, providing the JMX hooks in Infinispan to query a cache entry's age or last used time might not be enough in this case because to query Hibernate cache's, you'd have to build the corresponding CacheKey instances that Hibernate uses as wrappers for the cache keys and this is an internal implementation detail of Hibernate.
Brian, I'm trying to think of a way forward here but I had a question for you. I suppose what you really care about is getting a collection view that shows you the ids of all entities/collections and it's corresponding age, last usage time...etc.
I suppose that from an eviction planning perspective, this is more useful than you being able to provide an id or primary key and in return get the age and last used time of that particular entity/collection.
Am I right?
Exactly -- what I was looking for was a way to see a collection of everything in the local cache along with its age and last use. Thanks again,
Brian, currently the most suited information to guide you tweaking your eviction policies can be found via:
- Hits (Number of cache attribute hits),
- Misses(Number of cache attribute misses) ,
- HitRatio(Percentage hit/(hit+miss) ratio for the cache)
- Evictions (Number of cache eviction operations).
To get access to those you need to either modify the Infinispan configuration file or provide a new one where you enable global JMX statistics by adding this element under element:
<globalJmxStatistics enabled="true" jmxDomain="infinispan"/>
And also cache level JMX statistics by adding the following element under each cache type that you wanna be monitoring:
Once you have enabled these elements, you can use JConsole, JVisualVM or even Jopr to monitor these values in each of the cache instances. Remember to give it a -Dcom.sun.management.jmxremote.port at start time.
For the time being, the information that you request is considered internal and hence we won't provide a public view of it.