peek method

QuotaFetchResult? peek(
  1. String providerId
)

Synchronous, cache-only read for render paths (badge, /quota, app). Returns null when the entry is cold/expired — a background refresh is kicked in that case and the surface renders ….

Implementation

QuotaFetchResult? peek(String providerId) {
  final now = _clockNow;
  if (_unmetered.contains(providerId)) {
    return QuotaFetchResult.ok(ProviderQuota.unmetered(updatedAt: now));
  }
  if (!_adapters.containsKey(providerId)) {
    return const QuotaFetchResult.unknown('no quota source');
  }
  final entry = _cache[providerId];
  final fresh =
      entry != null &&
      now.difference(entry.fetchedAt) < ttl &&
      !_isResetOverdue(entry, now);
  if (fresh) return entry.result;
  _cache.remove(providerId);
  _kick(providerId);
  return null;
}