ehcache

net.sf.ehcache.management
Interface CacheStatisticsMBean

All Known Implementing Classes:
CacheStatistics

public interface CacheStatisticsMBean

Since:
1.3
Version:
$Id: CacheStatisticsMBean.java 519 2007-07-27 07:11:45Z gregluck $
Author:
Greg Luck

Method Summary
 void clearStatistics()
          Clears the statistic counters to 0 for the associated Cache.
 java.lang.String getAssociatedCacheName()
           
 long getCacheHits()
          The number of times a requested item was found in the cache.
 long getCacheMisses()
           
 long getInMemoryHits()
          Number of times a requested item was found in the Memory Store.
 long getObjectCount()
          Gets the number of elements stored in the cache.
 long getOnDiskHits()
          Number of times a requested item was found in the Disk Store.
 int getStatisticsAccuracy()
          Accurately measuring statistics can be expensive.
 java.lang.String getStatisticsAccuracyDescription()
          Accurately measuring statistics can be expensive.
 

Method Detail

clearStatistics

void clearStatistics()
Clears the statistic counters to 0 for the associated Cache.


getCacheHits

long getCacheHits()
The number of times a requested item was found in the cache.

Returns:
the number of times a requested item was found in the cache

getInMemoryHits

long getInMemoryHits()
Number of times a requested item was found in the Memory Store.

Returns:
the number of times a requested item was found in memory

getOnDiskHits

long getOnDiskHits()
Number of times a requested item was found in the Disk Store.

Returns:
the number of times a requested item was found on Disk, or 0 if there is no disk storage configured.

getCacheMisses

long getCacheMisses()
Returns:
the number of times a requested element was not found in the cache

getObjectCount

long getObjectCount()
Gets the number of elements stored in the cache. Caclulating this can be expensive. Accordingly, this method will return three different values, depending on the statistics accuracy setting.

Best Effort Size

This result is returned when the statistics accuracy setting is Statistics.STATISTICS_ACCURACY_BEST_EFFORT.

The size is the number of Elements in the MemoryStore plus the number of Elements in the DiskStore.

This number is the actual number of elements, including expired elements that have not been removed. Any duplicates between stores are accounted for.

Expired elements are removed from the the memory store when getting an expired element, or when attempting to spool an expired element to disk.

Expired elements are removed from the disk store when getting an expired element, or when the expiry thread runs, which is once every five minutes.

Guaranteed Accuracy Size

This result is returned when the statistics accuracy setting is Statistics.STATISTICS_ACCURACY_GUARANTEED.

This method accounts for elements which might be expired or duplicated between stores. It take approximately 200ms per 1000 elements to execute.

Fast but non-accurate Size

This result is returned when the statistics accuracy setting is Statistics.STATISTICS_ACCURACY_NONE.

The number given may contain expired elements. In addition if the DiskStore is used it may contain some double counting of elements. It takes 6ms for 1000 elements to execute. Time to execute is O(log n). 50,000 elements take 36ms.

Returns:
the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting.

getStatisticsAccuracy

int getStatisticsAccuracy()
Accurately measuring statistics can be expensive. Returns the current accuracy setting.

Returns:
one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT, Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONE

getStatisticsAccuracyDescription

java.lang.String getStatisticsAccuracyDescription()
Accurately measuring statistics can be expensive. Returns the current accuracy setting.

Returns:
a human readable description of the accuracy setting. One of "None", "Best Effort" or "Guaranteed".

getAssociatedCacheName

java.lang.String getAssociatedCacheName()
Returns:
the name of the Ehcache, or null is there no associated cache

ehcache