diff --git c/kernel/api/src/main/java/org/sakaiproject/memory/api/ehcache.xml w/kernel/api/src/main/java/org/sakaiproject/memory/api/ehcache.xml index a5e6ee0..9f85845 100644 --- c/kernel/api/src/main/java/org/sakaiproject/memory/api/ehcache.xml +++ w/kernel/api/src/main/java/org/sakaiproject/memory/api/ehcache.xml @@ -30,6 +30,7 @@ Optional attribute. A value of 0 means that and Element can live for infinity overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache has reached the maxInMemory limit. + statistics - Sets weather ehcache should collect statistics on the cache. --> @@ -71,7 +74,9 @@ eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="300" - overflowToDisk="false" /> + overflowToDisk="false" + statistics="true" + /> + overflowToDisk="false" + statistics="true" + /> + overflowToDisk="false" + statistics="true" + /> diff --git c/kernel/kernel-impl/src/main/java/org/sakaiproject/memory/impl/BasicMemoryService.java w/kernel/kernel-impl/src/main/java/org/sakaiproject/memory/impl/BasicMemoryService.java index 2e1b556..48c5dbc 100644 --- c/kernel/kernel-impl/src/main/java/org/sakaiproject/memory/impl/BasicMemoryService.java +++ w/kernel/kernel-impl/src/main/java/org/sakaiproject/memory/impl/BasicMemoryService.java @@ -266,11 +266,17 @@ public abstract class BasicMemoryService implements MemoryService, Observer 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(cache.getName() + ": " + - " count:" + cache.getStatistics().getObjectCount() + - " hits:" + hits + + " count:" + cache.getStatistics().getObjectCount()); + if (cache.isStatisticsEnabled()) { + buf.append(" hits:" + hits + " misses:" + misses + " hit%:" + hitRatio); + } else { + buf.append(" no statistics"); + } buf.append("\n"); }