public class CacheCounter extends Object implements CacheInstrument
| Modifier and Type | Class and Description |
|---|---|
static interface |
CacheCounter.Sizer
In order to find out how large a cache is, this callback interface is invoked
to give a "guesstimate" about how large the cache is at present.
|
| Modifier and Type | Field and Description |
|---|---|
protected AtomicLong |
hits |
protected AtomicLong |
misses |
protected AtomicLong |
missTime |
protected String |
name |
static CacheCounter.Sizer |
NOOP_SIZER
A sizer that always returns -1
|
protected CacheCounter.Sizer |
sizer |
| Constructor and Description |
|---|
CacheCounter(String name) |
CacheCounter(String name,
CacheCounter.Sizer sizer) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Instrument that) |
long |
getCacheSize() |
double |
getHitMissRatio() |
long |
getHits() |
long |
getMisses() |
long |
getMissTime() |
String |
getName() |
long |
getValue() |
long |
hit()
Call this to record a hits on the instrumented cache
|
long |
miss()
Call this to record a misses on the instrumented cache
|
<T> T |
miss(Callable<T> missObjectCreation)
Call this to record a misses on the instrumented cache and how long it took
to create the object that was missed.
|
long |
miss(long nanosecondsTaken)
Call this to record a misses on the instrumented cache and how long it took
to create the object that was missed.
|
public static final CacheCounter.Sizer NOOP_SIZER
protected final String name
protected final AtomicLong hits
protected final AtomicLong misses
protected final AtomicLong missTime
protected final CacheCounter.Sizer sizer
public CacheCounter(String name)
public CacheCounter(String name, CacheCounter.Sizer sizer)
public long hit()
public long miss()
public long miss(long nanosecondsTaken)
nanosecondsTaken - the time in nanoseconds it took to create the missed cache objectpublic <T> T miss(Callable<T> missObjectCreation)
This method takes a Callable that allows you to "create" the missed object and auto record the time it took to create the missed object.
missObjectCreation - the callable that creates the missed objectpublic String getName()
getName in interface Instrumentpublic long getValue()
getValue in interface Instrumentpublic int compareTo(Instrument that)
compareTo in interface Comparable<Instrument>public long getHits()
getHits in interface CacheInstrumentpublic long getMisses()
getMisses in interface CacheInstrumentpublic long getMissTime()
getMissTime in interface CacheInstrumentpublic double getHitMissRatio()
getHitMissRatio in interface CacheInstrumentpublic long getCacheSize()
getCacheSize in interface CacheInstrumentCopyright © 2016 Atlassian. All rights reserved.