如何从 Coherence 缓存获取统计数据?
我正在为客户研究 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());
}
I'm looking into Oracle Coherence for a client, and one of the things they are interested in is getting statistical information back from it to understand usage patterns etc.
I know I can get some information from JMX, however there is also a CacheStatistics interface provided which I'd like to get data from. However I can't see how I should go from having a cache object to getting its statistics.
The code below is my poc implementation, and I can use the 'cache' object to put and get values from the cache, is there a way to link from the cache to the associated statistics? I guess I'm missing something simple somewhere...
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());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果缓存是近缓存,那么您可以执行以下操作。还可以检查获取 backcache 的 API 以查看其统计信息。
If the cache is a nearcache, then you can do the following.Also check the API to get backcache to see its statistics.