Class FcCacheMetrics
java.lang.Object
org.frontcache.cache.FcCacheMetrics
Cache read outcomes, counted per tier.
Why these are counted here and not derived
Hit ratio is the number an operator alerts on, and nothing in the process could produce it before this class. The dashboard'sCache-Hit command counts cache lookups - every one of
them, hit or miss - because it measures the call, not the answer. The request log has the per-request
verdict but is a log, not a metric. So the counters are taken where the answer is actually known:
inside each getFromCacheImpl, which is the single read path every cache processor goes
through (CacheProcessorBase.getFromCache → FC_ThroughCache → the impl).
Why the tier is part of it
"Hit ratio 90%" and "hit ratio 90%, nine tenths of it off disk" call for different actions - the second says L1 is undersized. Splitting hits by tier is what makes the number actionable, and it is cheap: the tier is already known at the point the hit happens.Monotonic, never rolling
UnlikeFcCommandMetrics, which keeps a rolling window because the
SSE dashboard needs a 10-second view, these only ever go up. Their consumer is Prometheus, which
computes its own windows with rate() - and a counter that decreases reads as a process
restart there. Nothing needs the rolling form, so it is not built.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhere a cache read was answered from, or that it was not. -
Method Summary
Modifier and TypeMethodDescriptionstatic longcount(FcCacheMetrics.Outcome outcome) static voidrecord(FcCacheMetrics.Outcome outcome) Records one cache read.static voidrecordHitOrMiss(Object cachedResponse, FcCacheMetrics.Outcome hitOutcome) Convenience for the common two-branch case: a resolved response, or null for a miss.static voidreset()Test seam - back to zero.
-
Method Details
-
record
Records one cache read. Called on the request path, so it is aLongAdderincrement and nothing else - no allocation, no lock, no branch on whether export is even enabled. Counting unconditionally keeps the numbers correct for a node that has export turned on later, and costs less than the check would. -
recordHitOrMiss
Convenience for the common two-branch case: a resolved response, or null for a miss. -
count
- Returns:
- reads with this outcome since JVM start
-
reset
public static void reset()Test seam - back to zero.
-