public class SmoothlyDecayingRollingHitRatio extends Object implements HitRatio
Concurrency properties:
Usage recommendations:
Performance considerations:
| Constructor and Description |
|---|
SmoothlyDecayingRollingHitRatio(Duration rollingWindow,
int numberChunks)
Constructs the chunked hit-ratio divided by
numberChunks. |
SmoothlyDecayingRollingHitRatio(Duration rollingWindow,
int numberChunks,
Ticker ticker) |
| Modifier and Type | Method and Description |
|---|---|
int |
getChunkCount() |
double |
getHitRatio()
Returns the ratio between hits and misses
|
Duration |
getRollingWindow() |
String |
toString() |
void |
update(int hitCount,
int totalCount)
Registers an result of bulk operations.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitincrementHitCount, incrementMissCountpublic SmoothlyDecayingRollingHitRatio(Duration rollingWindow, int numberChunks)
numberChunks.
The hit-ratio will invalidate one chunk each time when rollingWindow/numberChunks millis has elapsed,
except oldest chunk which invalidated continuously.
The memory consumed by hit-ratio and latency of ratio calculation depend directly from numberChunksrollingWindow - the rolling time window durationnumberChunks - The count of chunk to splitpublic Duration getRollingWindow()
public int getChunkCount()
public void update(int hitCount,
int totalCount)
HitRatioExample of usage:
Set<Something> cachedValues = cache.get(keys);
hitRatio.update(cachedValues.size(), keys.size());
public double getHitRatio()
HitRatiogetHitRatio in interface HitRatioCopyright © 2020. All rights reserved.