I should have been more clear here. Stepping back there are a few different problems with the stats api/spi that we can maybe look at individually...
- Inconsistency in how L2 cache "stats" relative to a specific type of data are exposed. For entity and collection stats, L2 cache stats are only available on the SecondLevelCacheStatstics - there is no EntityStatistics#getCacheHitCount nor CollectionStatistics#getCacheHitCount while there are QueryStatistics#getCacheHitCount and NaturalIdCacheStatistics#getHitCount. That is inconsistent. We should have the same answer for all of these imo.
- Are L2 cache region-wide stats useful (when multiple "things" are stored there)? Vlad and I discussed this on HipChat if you want to see what this is about. Basically... <quote>but the total number of hits/misses/puts in region "a.b.c" over all 50 entities, 200 collections and 10 natrual-ids stored in that single region... I just dont get the usefulness</quote>
- At the very least, accessing natural-id cache stats is going to need a more difficult non-API change... it currently accepts the name of the region. It really should be the name of the entity.
I will also be updating the description to add a 3rd option and hopefully better describe each and their implications |