01: package ri.cache;
02:
03: import javax.cache.CacheStatistics;
04: import java.util.concurrent.atomic.AtomicInteger;
05:
06: class ReferenceStatistics implements CacheStatistics {
07:
08: private final AtomicInteger hitCount = new AtomicInteger();
09: private final AtomicInteger missCount = new AtomicInteger();
10:
11: void incrementHits() {
12: hitCount.incrementAndGet();
13: }
14:
15: void incrementMisses() {
16: missCount.incrementAndGet();
17: }
18:
19: void addToHits(int n) {
20: hitCount.addAndGet(n);
21: }
22:
23: void addToMisses(int n) {
24: missCount.addAndGet(n);
25: }
26:
27: public long getSize() {
28: // @@@
29: return 0;
30: }
31:
32: public long getCacheHits() {
33: return hitCount.get();
34: }
35:
36: public long getCacheMisses() {
37: return missCount.get();
38: }
39:
40: public void clearStatistics() {
41: hitCount.set(0);
42: missCount.set(0);
43: }
44: }
|