當前位置: 首頁>>代碼示例>>Java>>正文


Java CacheManager.getCacheNames方法代碼示例

本文整理匯總了Java中net.sf.ehcache.CacheManager.getCacheNames方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheManager.getCacheNames方法的具體用法?Java CacheManager.getCacheNames怎麽用?Java CacheManager.getCacheNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.ehcache.CacheManager的用法示例。


在下文中一共展示了CacheManager.getCacheNames方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resetAllCaches

import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
public static void resetAllCaches() throws CacheException, IOException {
  final CacheManager cacheManager = CacheManager.getInstance();
  final String[] cacheNames = cacheManager.getCacheNames();
  for (int i = 0; i < cacheNames.length; i++) {
    final String cacheName = cacheNames[i];
    if (cacheName.equals("retention_cache")) continue;
    //if (log.isDebugEnabled()) log.debug("cache hits before setup: " + cacheName + "/" + cache.getHitCount());
    cacheManager.getCache(cacheName).removeAll();
  }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:11,代碼來源:CacheUtils.java

示例2: makeCacheStatsPanel

import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
/**
 * Creates cache stats panel.
 */
private Panel makeCacheStatsPanel() {
  final MessagePanel result = new MessagePanel("Cache statistis");
  try {
    final GridIterator gi = new GridIterator(result.getUserPanel(), 5);
    gi.add(new BoldCommonLabel("Name"))
            .add(new BoldCommonLabel("Hit count"))
            .add(new BoldCommonLabel("Miss count expired"))
            .add(new BoldCommonLabel("Miss count not found"))
            .add(new BoldCommonLabel("Miss percent"))
            ;
    final CacheManager cacheMan = CacheManager.getInstance();
    final String[] cacheNames = cacheMan.getCacheNames();
    Arrays.sort(cacheNames);
    int totalHitCount = 0;
    int totalMissCount = 0;
    for (int i = 0; i < cacheNames.length; i++) {
      // get cache
      final String cacheName = cacheNames[i];
      final Cache cache = cacheMan.getCache(cacheName);
      final int hitCount = cache.getHitCount();
      final int missCountExpired = cache.getMissCountExpired();
      final int missCountNotFound = cache.getMissCountNotFound();
      final int missCount = missCountExpired + missCountNotFound;
      final int accessCount = missCount + hitCount;
      final int missPercent = accessCount == 0 ? 0 : (missCount * 100) / accessCount;
      totalHitCount += hitCount;
      totalMissCount += missCount;
      // add attrs
      gi.add(new AboutLabel(cacheName));
      gi.add(new AboutLabel(Integer.toString(hitCount)));
      gi.add(new AboutLabel(Integer.toString(missCountExpired)));
      gi.add(new AboutLabel(Integer.toString(missCountNotFound)));
      final CommonLabel lbMissPercent = new AboutLabel(Integer.toString(missPercent));
      lbMissPercent.setAlignX(Layout.RIGHT);
      gi.add(lbMissPercent);
    }
    // add total
    final int totalAccessCount = totalHitCount + totalMissCount;
    final int totalMissPercent = totalAccessCount == 0 ? 0 : (totalMissCount * 100) / totalAccessCount;
    gi.add(new CommonLabel("--- Total -- "));
    gi.add(new CommonLabel(""));
    gi.add(new CommonLabel(""));
    gi.add(new CommonLabel(""));
    gi.add(new CommonLabel(Integer.toString(totalMissPercent)));
  } catch (CacheException e) {
    result.showErrorMessage("Error getting cache stats: " + e.toString());
  }
  return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:53,代碼來源:AboutPage.java


注:本文中的net.sf.ehcache.CacheManager.getCacheNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。