|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.jcache.JCacheStatistics
public class JCacheStatistics
A jsr107 CacheStatistics decorator for an ehcache Statistics class. An immutable Cache statistics implementation}
This is like a value object, with the added ability to clear cache statistics on the cache. That ability does not survive any Serialization of this class. On deserialization the cache can be considered disconnected. The accuracy of these statistics are determined by the value of {#getStatisticsAccuracy()} at the time the statistic was computed. This can be changed by settingCache.setStatisticsAccuracy(int)
.
Because this class maintains a reference to an Ehcache, any references held to this class will precent the Ehcache
from getting garbage collected.
Field Summary |
---|
Fields inherited from interface net.sf.jsr107cache.CacheStatistics |
---|
STATISTICS_ACCURACY_BEST_EFFORT, STATISTICS_ACCURACY_GUARANTEED, STATISTICS_ACCURACY_NONE |
Constructor Summary | |
---|---|
JCacheStatistics(Statistics statistics)
Constructs an object from an ehcache statistics object |
Method Summary | |
---|---|
void |
clearStatistics()
Clears the statistic counters to 0 for the associated Cache. |
float |
getAverageGetTime()
The average time for cache gets since either the cache was created or statistics were cleared |
int |
getCacheHits()
The number of times a requested item was found in the cache. |
int |
getCacheMisses()
Warning. |
long |
getEvictionCount()
Gets the number of cache evictions, since the cache was created, or statistics were cleared. |
int |
getObjectCount()
Gets the number of elements stored in the cache. |
int |
getStatisticsAccuracy()
Accurately measuring statistics can be expensive. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JCacheStatistics(Statistics statistics)
statistics
- the Statistics object this object decorates.Method Detail |
---|
public int getStatisticsAccuracy()
getStatisticsAccuracy
in interface net.sf.jsr107cache.CacheStatistics
CacheStatistics.STATISTICS_ACCURACY_BEST_EFFORT
, CacheStatistics.STATISTICS_ACCURACY_GUARANTEED
, CacheStatistics.STATISTICS_ACCURACY_NONE
public void clearStatistics()
clearStatistics
in interface net.sf.jsr107cache.CacheStatistics
public int getCacheHits()
getCacheHits
in interface net.sf.jsr107cache.CacheStatistics
public int getCacheMisses()
getCacheMisses
in interface net.sf.jsr107cache.CacheStatistics
public int getObjectCount()
Statistics.STATISTICS_ACCURACY_BEST_EFFORT
.
The size is the number of Element
s in the MemoryStore
plus
the number of Element
s 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.
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.
CacheStatistics.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.
getObjectCount
in interface net.sf.jsr107cache.CacheStatistics
public float getAverageGetTime()
public long getEvictionCount()
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |