updateStreamCache<T> method

void updateStreamCache<T>(
  1. String cacheKey,
  2. T data,
  3. DateTime timestamp
)

Mirror a ZenStreamQuery's latest event into the memory cache without spawning a background expiry timer (so widget tests using streams never fail with pending timers; expiration is still checked lazily via isExpired).

Implementation

void updateStreamCache<T>(String cacheKey, T data, DateTime timestamp) {
  final streamQuery = _streamQueries[cacheKey];
  final cacheTime =
      streamQuery?.config.cacheTime ?? const Duration(minutes: 5);
  _cache[cacheKey]?.expiryTimer?.cancel();
  _cache[cacheKey] = _CacheEntry<T>(
    data: data,
    timestamp: timestamp,
    cacheTime: cacheTime,
  );
}