本文整理匯總了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();
}
}
示例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;
}