getOrPutFor static method
Resolves key against an explicit coherent metrics snapshot.
Implementation
static double getOrPutFor(
DimenMetrics metrics,
CacheKey key,
double Function() compute,
) {
if (!_enabled || key.hasCustomSensitivity || shouldBypassCache(key)) {
return compute();
}
final cache = _cacheFor(metrics);
final hit = cache.entries[key];
if (hit != null) {
_hits++;
return hit;
}
_misses++;
final value = compute();
if (value.isFinite) cache.insert(key, value);
return value;
}