caching - Ehcache Statistics by key - Stack Overflow
You can't track misses on a per-key basis because the statistics are stored on object IN the cache and if there was a miss, there would be no element in the cache to track it. But if you want a hit-count for all the keys in a cache you'd need to do something like:
public Map<Object,long> getKeyHits(Ehcache cache) { Map<Object,long> hitMap = new HashMap<Object,long>(); Map<Object,Element> allElements = cache.getAll(cache.getKeys()); for (Object key : allElements.keySet()) { hitMap.put(key, allElements.get(key).hitCount()); } return hitMap; }Read full article from caching - Ehcache Statistics by key - Stack Overflow
No comments:
Post a Comment