/** {@inheritDoc} */ public void notifyRemoveAll(Ehcache cache) { if (!statisticsEnabled.get()) { return; } for (CacheUsageListener l : listeners) { l.notifyRemoveAll(); } }
/** {@inheritDoc} */ public void setStatisticsEnabled(boolean enableStatistics) { if (enableStatistics) { clearStatistics(); } statisticsEnabled.set(enableStatistics); for (CacheUsageListener l : listeners) { l.notifyStatisticsEnabledChanged(enableStatistics); } }
/** {@inheritDoc} */ public void notifyElementExpired(Ehcache cache, Element element) { if (!statisticsEnabled.get()) { return; } cacheElementExpired.incrementAndGet(); for (CacheUsageListener l : listeners) { l.notifyCacheElementExpired(); } }
/** {@inheritDoc} */ public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { if (!statisticsEnabled.get()) { return; } cacheElementUpdated.incrementAndGet(); for (CacheUsageListener l : listeners) { l.notifyCacheElementUpdated(); } }
/** {@inheritDoc} */ public void cacheMissNotFound() { if (!statisticsEnabled.get()) { return; } cacheMissNotFound.incrementAndGet(); for (CacheUsageListener l : listeners) { l.notifyCacheMissedWithNotFound(); } }
/** {@inheritDoc} */ public void cacheHitOnDisk() { if (!statisticsEnabled.get()) { return; } cacheHitOnDiskCount.incrementAndGet(); for (CacheUsageListener l : listeners) { l.notifyCacheHitOnDisk(); } }
/** {@inheritDoc} */ public void setStatisticsAccuracy(int statisticsAccuracy) { if (!Statistics.isValidStatisticsAccuracy(statisticsAccuracy)) { throw new IllegalArgumentException( "Invalid statistics accuracy value: " + statisticsAccuracy); } this.statisticsAccuracy.set(statisticsAccuracy); for (CacheUsageListener l : listeners) { l.notifyStatisticsAccuracyChanged(statisticsAccuracy); } }
/** {@inheritDoc} */ public void clearStatistics() { cacheHitInMemoryCount.set(0); cacheHitOnDiskCount.set(0); cacheMissExpired.set(0); cacheMissNotFound.set(0); cacheElementEvictedCount.set(0); totalGetTimeTakenMillis.set(0); cacheElementRemoved.set(0); cacheElementExpired.set(0); cacheElementPut.set(0); cacheElementUpdated.set(0); minGetTimeMillis.set(MIN_MAX_DEFAULT_VALUE); maxGetTimeMillis.set(MIN_MAX_DEFAULT_VALUE); for (CacheUsageListener l : listeners) { l.notifyStatisticsCleared(); } }
/** {@inheritDoc} */ public void addGetTimeMillis(long millis) { if (!statisticsEnabled.get()) { return; } totalGetTimeTakenMillis.addAndGet(millis); for (CacheUsageListener l : listeners) { l.notifyTimeTakenForGet(millis); } if (minGetTimeMillis.get() == MIN_MAX_DEFAULT_VALUE || (millis < minGetTimeMillis.get() && millis > 0)) { minGetTimeMillis.set(millis); } if (maxGetTimeMillis.get() == MIN_MAX_DEFAULT_VALUE || (millis > maxGetTimeMillis.get() && millis > 0)) { maxGetTimeMillis.set(millis); } }
/** {@inheritDoc} */ public void dispose() { for (CacheUsageListener l : listeners) { l.dispose(); } }