public Long call() throws Exception { return cache.getStatistics().getOnDiskHits(); } }));
/** * Number of times a requested item was found in the Disk Store. * * @return the number of times a requested item was found on Disk, or 0 if there is no disk storage configured. */ public long getOnDiskHits() { updateIfNeeded(); return statistics.getOnDiskHits(); }
/** * Generate some stats for this cache. * Note that this is not cheap so do not use it very often. * * @param cache an Ehcache * @return the stats of this cache as a string */ protected static String generateCacheStats(Ehcache cache) { StringBuilder sb = new StringBuilder(); sb.append(cache.getName()).append(":"); // this will make this costly but it is important to get accurate settings cache.setStatisticsAccuracy(Statistics.STATISTICS_ACCURACY_GUARANTEED); Statistics stats = cache.getStatistics(); final long memSize = cache.getMemoryStoreSize(); final long diskSize = cache.getDiskStoreSize(); final long size = memSize + diskSize; final long hits = stats.getCacheHits(); final long misses = stats.getCacheMisses(); final String hitPercentage = ((hits + misses) > 0) ? ((100l * hits) / (hits + misses)) + "%" : "N/A"; final String missPercentage = ((hits + misses) > 0) ? ((100l * misses) / (hits + misses)) + "%" : "N/A"; sb.append(" Size: ").append(size).append(" [memory:").append(memSize).append(", disk:").append(diskSize) .append("]"); sb.append(", Hits: ").append(hits).append(" [memory:").append(stats.getInMemoryHits()).append(", disk:") .append(stats.getOnDiskHits()).append("] (").append(hitPercentage).append(")"); sb.append(", Misses: ").append(misses).append(" (").append(missPercentage).append(")"); return sb.toString(); }
/** * Generate some stats for this cache. * Note that this is not cheap so do not use it very often. * * @param cache an Ehcache * @return the stats of this cache as a string */ protected static String generateCacheStats(Ehcache cache) { StringBuilder sb = new StringBuilder(); sb.append(cache.getName()).append(":"); // this will make this costly but it is important to get accurate settings cache.setStatisticsAccuracy(Statistics.STATISTICS_ACCURACY_GUARANTEED); Statistics stats = cache.getStatistics(); final long memSize = cache.getMemoryStoreSize(); final long diskSize = cache.getDiskStoreSize(); final long size = memSize + diskSize; final long hits = stats.getCacheHits(); final long misses = stats.getCacheMisses(); final String hitPercentage = ((hits+misses) > 0) ? ((100l * hits) / (hits + misses)) + "%" : "N/A"; final String missPercentage = ((hits+misses) > 0) ? ((100l * misses) / (hits + misses)) + "%" : "N/A"; sb.append(" Size: ").append(size).append(" [memory:").append(memSize).append(", disk:").append(diskSize).append("]"); sb.append(", Hits: ").append(hits).append(" [memory:").append(stats.getInMemoryHits()).append(", disk:").append(stats.getOnDiskHits()).append("] (").append(hitPercentage).append(")"); sb.append(", Misses: ").append(misses).append(" (").append(missPercentage).append(")"); return sb.toString(); }
/** * Generate some stats for this cache. * Note that this is not cheap so do not use it very often. * * @param cache an Ehcache * @return the stats of this cache as a string */ protected static String generateCacheStats(Ehcache cache) { StringBuilder sb = new StringBuilder(); sb.append(cache.getName()).append(":"); // this will make this costly but it is important to get accurate settings cache.setStatisticsAccuracy(Statistics.STATISTICS_ACCURACY_GUARANTEED); Statistics stats = cache.getStatistics(); final long memSize = cache.getMemoryStoreSize(); final long diskSize = cache.getDiskStoreSize(); final long size = memSize + diskSize; final long hits = stats.getCacheHits(); final long misses = stats.getCacheMisses(); final String hitPercentage = ((hits + misses) > 0) ? ((100l * hits) / (hits + misses)) + "%" : "N/A"; final String missPercentage = ((hits + misses) > 0) ? ((100l * misses) / (hits + misses)) + "%" : "N/A"; sb.append(" Size: ").append(size).append(" [memory:").append(memSize).append(", disk:").append(diskSize) .append("]"); sb.append(", Hits: ").append(hits).append(" [memory:").append(stats.getInMemoryHits()).append(", disk:") .append(stats.getOnDiskHits()).append("] (").append(hitPercentage).append(")"); sb.append(", Misses: ").append(misses).append(" (").append(missPercentage).append(")"); return sb.toString(); }
/** * {@inheritDoc} */ public double getOnDiskHitPercentage() { updateIfNeeded(); long hits = statistics.getOnDiskHits(); long misses = statistics.getOnDiskMisses(); long total = hits + misses; return getPercentage(hits, total); } }
state.setEvictionCount(statistics.getEvictionCount()); state.setInMemoryHits(statistics.getInMemoryHits()); state.setOnDiskHits(statistics.getOnDiskHits()); state.setMaxElementsInMemory(cache.getCacheConfiguration().getMaxElementsInMemory()); state.setMaxElementsOnDisk(cache.getCacheConfiguration().getMaxElementsOnDisk());