|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.rcache.decorator.CacheProfiler<K,V>
K
- the type of keys maintained by this cacheV
- the type of cached valuespublic final class CacheProfiler<K,V>
Keeps track of the average execution time for each operation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface net.sourceforge.rcache.Cache |
---|
Cache.Operation |
Field Summary |
---|
Fields inherited from interface net.sourceforge.rcache.Cache |
---|
DEFAULT_CONCURRENCY_LEVEL, DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR |
Constructor Summary | |
---|---|
CacheProfiler(Cache<K,V> cache)
Creates an instance. |
Method Summary | |
---|---|
void |
clear()
Removes all entries from this cache. |
V |
get(java.lang.Object key)
Returns the value to which this cache maps the specified key. |
double |
getAverage(Cache.Operation op)
Gets the average execution time of an operation. |
double[] |
getAverages()
Gets the average execution time of all this cache operations. |
long |
getNum(Cache.Operation op)
Gets the number of registered invocations to the specified Cache operation. |
long[] |
getNums()
Gets the number of invocations to each Cache operation. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this cache, but only if no value is associated yet. |
V |
remove(java.lang.Object key)
Removes the entry for this key from this cache if present. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CacheProfiler(Cache<K,V> cache)
cache
- The cache instance to wrapMethod Detail |
---|
public V get(java.lang.Object key)
Returns the value to which this cache maps the specified key. Returns null if the cache contains no entry for this key. A return value of null does not necessarily indicate that the cache contains no entry for the key; it's also possible that the cache explicitly maps the key to null
.Although this method should use K for the key type, it
is left as Object to keep this interface compatible with
Map
.
get
in interface Cache<K,V>
key
- key whose associated value is to be returned.
public V put(K key, V value)
Associates the specified value with the specified key in this cache, but only if no value is associated yet. If the cache previously contained an entry for this key, the old value is returned, but not replaced.
This method is equivalent to the putIfAbsent from the
ConcurrentMap
class, as it is more
appropriate for a cache than the original one from Map
.
put
in interface Cache<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
public V remove(java.lang.Object key)
Removes the entry for this key from this cache if present.
Although this method should use K for the key type, it
is left as Object to keep this interface compatible with
Map
.
remove
in interface Cache<K,V>
key
- key whose entry is to be removed from the cache.
public void clear()
Removes all entries from this cache.
This method must be handled very carefully, as it will break the assumption of unique instances for cached factories.
clear
in interface Cache<K,V>
public double getAverage(Cache.Operation op)
op
- The operation
public double[] getAverages()
Operation
enumpublic long getNum(Cache.Operation op)
op
- Operation
public long[] getNums()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |