|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.Statistics
public class Statistics
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.
The STATISTICS_ACCURACY_BEST_EFFORT
, STATISTICS_ACCURACY_GUARANTEED
and STATISTICS_ACCURACY_NONE
constants have the same values as in JSR107.
Field Summary | |
---|---|
static int |
STATISTICS_ACCURACY_BEST_EFFORT
Best efforts accuracy setting. |
static int |
STATISTICS_ACCURACY_GUARANTEED
Guaranteed accuracy setting. |
static int |
STATISTICS_ACCURACY_NONE
Fast but not accurate setting. |
Constructor Summary | |
---|---|
Statistics(Ehcache cache,
int statisticsAccuracy,
long cacheHits,
long onDiskHits,
long inMemoryHits,
long misses,
long size,
float averageGetTime,
long evictionCount)
Creates a new statistics object, associated with a Cache |
Method Summary | |
---|---|
void |
clearStatistics()
Clears the statistic counters to 0 for the associated Cache. |
Ehcache |
getAssociatedCache()
|
java.lang.String |
getAssociatedCacheName()
|
float |
getAverageGetTime()
The average get time. |
long |
getCacheHits()
The number of times a requested item was found in the cache. |
long |
getCacheMisses()
|
long |
getEvictionCount()
Gets the number of cache evictions, since the cache was created, or statistics were cleared. |
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. |
java.lang.String |
toString()
Returns a String representation of the Ehcache statistics. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STATISTICS_ACCURACY_NONE
public static final int STATISTICS_ACCURACY_BEST_EFFORT
public static final int STATISTICS_ACCURACY_GUARANTEED
Constructor Detail |
---|
public Statistics(Ehcache cache, int statisticsAccuracy, long cacheHits, long onDiskHits, long inMemoryHits, long misses, long size, float averageGetTime, long evictionCount)
cache
- The cache that clearStatistics()
will call, if not disconnectedstatisticsAccuracy
- cacheHits
- onDiskHits
- inMemoryHits
- misses
- size
- Method Detail |
---|
public void clearStatistics()
public long getCacheHits()
public long getInMemoryHits()
public long getOnDiskHits()
public long getCacheMisses()
public long getObjectCount()
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_ACCURACY_GUARANTEED
.
This method accounts for elements which might be expired or duplicated between stores. It take approximately
200ms per 1000 elements to execute.
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.
public int getStatisticsAccuracy()
STATISTICS_ACCURACY_BEST_EFFORT
, STATISTICS_ACCURACY_GUARANTEED
, STATISTICS_ACCURACY_NONE
public java.lang.String getStatisticsAccuracyDescription()
public java.lang.String getAssociatedCacheName()
public Ehcache getAssociatedCache()
public final java.lang.String toString()
String
representation of the Ehcache
statistics.
toString
in class java.lang.Object
public float getAverageGetTime()
public long getEvictionCount()
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |