2011-05-10 49 views
3

我期待到Oracle Coherence的一個客戶,和他們有興趣越來越統計信息,回明白使用模式等如何從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()); 
    } 
+0

鏈接到API將很方便。 – 2011-05-10 13:21:40

+0

對不起,在這裏你去:http://download.oracle.com/docs/cd/E18686_01/coh.37/e18683/toc.htm – MrChris 2011-05-10 13:27:48

回答

0

如果緩存是nearcache,那麼你可以做的following.Also檢查API來獲取backcache看到它的統計數據。

if (cache instanceof NearCache) { 
    System.out.println("\tstatistics :" + ((LocalCache)((NearCache)cache).getFrontMap()).getCacheStatistics()); 
} 
+1

本地緩存getCacheStatistics()已棄用。有沒有其他方法可以獲得統計信息? – Nishu 2015-12-07 14:42:26