我正在为客户研究 Oracle Coherence,他们感兴趣的一件事是从中获取统计信息以了解使用模式等。
我知道我可以从 JMX 获得一些信息,但是还提供了一个 CacheStatistics 接口,我想从中获取数据。但是我看不出我应该如何从拥有一个缓存对象到获取它的统计信息。
下面的代码是我的 poc 实现,我可以使用“缓存”对象从缓存中放置和获取值,有没有办法从缓存链接到相关的统计信息?我想我在某处遗漏了一些简单的东西......
NamedCache cache = CacheFactory.getCache(cacheName);
if(cache.isActive()){
//Wrong because there's no link to the cache..
SimpleCacheStatistics scs = new SimpleCacheStatistics();
long hits = scs.getCacheHits();
System.out.println("Cache hits:" +hits+"\n : "+scs.toString());
}