public long getNumberOfActiveUsers() { Statistics stats = _cache.getStatistics(); return stats.getObjectCount(); }
public void printStatistics() { Statistics statistics = namespaceCache.getStatistics(); if (statistics != null) { //TODO: use a logger please System.out.println("Namespace Cache Statisitics: "); System.out.println("--Hits: \t" + statistics.getCacheHits()); System.out.println("--Misses: \t" + statistics.getCacheMisses()); System.out.println("--Total Count: \t" + statistics.getObjectCount()); } } }
public void printStatistics() { Statistics statistics = namespaceCache.getStatistics(); if (statistics != null) { //TODO: use a logger please System.out.println("Namespace Cache Statisitics: "); System.out.println("--Hits: \t" + statistics.getCacheHits()); System.out.println("--Misses: \t" + statistics.getCacheMisses()); System.out.println("--Total Count: \t" + statistics.getObjectCount()); } } }
return statistics.getObjectCount();
@Path("stats") @Produces("text/plain") public class StatsResource { @Inject private CacheManager cacheManager; @GET public String stats() { StringBuffer sb = StringBuffer(); /* get stats for all known caches */ for (String name : cacheManager.getCacheNames()) { Cache cache = cacheManager.getCache(name); Statistics stats = cache.getStatistics(); sb.append(String.format("%s: %s objects, %s hits, %s misses\n", name, stats.getObjectCount(), stats.getCacheHits(), stats.getCacheMisses() )); } return sb.toString(); } }
@Override public String getDescription() { final StringBuilder buf = new StringBuilder(); buf.append(cache.getName()).append(" Ehcache"); if (loader != null) { buf.append(" Loader"); } if (cacheEventListener != null) { buf.append(" Listener"); } if (isDistributed()) { buf.append(" Distributed"); } final long hits = cache.getStatistics().getCacheHits(); final long misses = cache.getStatistics().getCacheMisses(); final long total = hits + misses; final long hitRatio = ((total > 0) ? ((100l * hits) / total) : 0); // Even when we're not collecting statistics ehcache knows how many objects are in the cache buf.append(": ").append(" count:").append(cache.getStatistics().getObjectCount()); if (cache.isStatisticsEnabled()) { buf.append(" hits:").append(hits).append(" misses:").append(misses).append(" hit%:").append(hitRatio); } else { buf.append(" NO statistics (not enabled for cache)"); } return buf.toString(); }
static void logRegionStatistics(Ehcache cache, Logger log) { Statistics stats = cache.getStatistics(); log.info("region ["+cache.getName()+"] statistics: "); log.info("objectCount: "+stats.getObjectCount() + ", maxTimeToLive:"+ cache.getCacheConfiguration().getTimeToLiveSeconds()+" s"); log.info("cacheHits:"+ stats.getCacheHits() +", cacheMisses:"+ stats.getCacheMisses()+", inMemoryHits:"+ stats.getInMemoryHits()); }
public CacheStatistics getStatistics() { Statistics stats = getEHCache().getStatistics(); return new CacheStatistics( stats.getObjectCount(), stats.getCacheMisses(), stats.getCacheHits() ); }
public Map<String, CacheStatistics> getAllCacheStatistics() { final Map<String, CacheStatistics> allCacheStatistics = new TreeMap<>(CaseInsenstivieStringComparator.INSTANCE); for (final String cacheName : this.cacheManager.getCacheNames()) { final Cache cache = this.cacheManager.getCache(cacheName); if (null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) { final CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); final Statistics statistics = cache.getStatistics(); final CacheStatistics cacheStatistics = new CacheStatistics(); cacheStatistics.hits = statistics.getCacheHits(); cacheStatistics.misses = statistics.getCacheMisses(); cacheStatistics.size = statistics.getObjectCount(); cacheStatistics.maxSize = cacheConfiguration.getMaxElementsInMemory() + cacheConfiguration.getMaxElementsOnDisk(); allCacheStatistics.put(cacheName, cacheStatistics); } } return allCacheStatistics; }
public Map<String, CacheStatistics> getAllCacheStatistics() { final Map<String, CacheStatistics> allCacheStatistics = new TreeMap<>(CaseInsenstivieStringComparator.INSTANCE); for (final String cacheName : this.cacheManager.getCacheNames()) { final Cache cache = this.cacheManager.getCache(cacheName); if (null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) { final CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); final Statistics statistics = cache.getStatistics(); final CacheStatistics cacheStatistics = new CacheStatistics(); cacheStatistics.hits = statistics.getCacheHits(); cacheStatistics.misses = statistics.getCacheMisses(); cacheStatistics.size = statistics.getObjectCount(); cacheStatistics.maxSize = cacheConfiguration.getMaxElementsInMemory() + cacheConfiguration.getMaxElementsOnDisk(); allCacheStatistics.put(cacheName, cacheStatistics); } } return allCacheStatistics; }
if (calculateObjectCount) state.setObjectCount(statistics.getObjectCount());