English 中文(简体)
重要数据
原标题:Ehcache Statistics by key

我有兴趣获得关于我所管理的Ehcache的统计数字。

我想看到一段时间内某个关键人物的点击/米sses次数。 也许以地图的形式。 例如:


Key A had 30 hits and 2 misses
Key B had 400 hits and 100 misses
Key C had 2 hits and 1 misses
Key D had 150 hits and 10 misses

我研究了文件(SampledCacheStatistics、SampledCacheStatisticsImpl、SampledCacheStatisticsWrapper等),我为此投入了很紧的时间。

是否有其他经验执行?

在这个问题上的任何帮助或想法都会得到妇女、儿童和社会福利部的赞赏!

问题回答

rel=“noretinger”>EhCache Monitor rel=“noreferer” http://ehcache.org/documentation/monitor.html

提供以下方案:

    CacheManager cacheManager = CacheManager.getInstance();
    String[] cacheNames = cacheManager.getCacheNames();
    for (int i = 0; i < cacheNames.length; i++) {
        String cacheName = cacheNames[i];
        System.out.println(cacheName+" - "+ cacheManager.getCache(cacheName).getStatistics().toString());
    }

您可以按部就班地追踪,因为统计数字储存在海滩的物体上,如果存在错误,则在海滩上没有跟踪数据。 但是,如果你想要打上所有关键人物的记号,那么你需要做这样的事:

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;
}

如果你看一看整个海滩(或你希望跟踪点)的合计统计数据,你就可以把统计学点上。 见





相关问题
Write-though caching of large data sets in WCF?

We ve got a smart client that talks to a SQL Server database via WCF, displaying the entities in the database, and allowing the user to edit those entities. Some of the WCF calls return a large data ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

how to tell clicking "back" to load cache?

I would like for my site when someone clicks "Back" or "Forward" for the server to tell the browser to load the cache instead of reloading the entire page. I ve tested some headers and done research, ...

java plugin cache and dynamic IP host

I m trying to use Amazon S3 and Amazon Cloudfront CDN to deliver the jar files of my applet application. I m seeing several cache misses of my jars by the java plugin. This is a show-stopper for me, ...

Frequently Used metadata Hashmap

Are there any implementations of a static size hashtable that limits the entries to either the most recently or most frequently used metadata? I would prefer not to keep track of this information ...

PHP - Memcache - HTML Caching

I would like to create a caching system that will bypass some mechanisms in order to improve the performance. I have some examples: 1-) I have a dynamic PHP page that is updated every hour. The page ...

Performance of Sql subqueriesfunctions

I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...

热门标签