updateCache<T> method

void updateCache<T>(
  1. String queryKey,
  2. T data,
  3. DateTime timestamp
)

Update cache for a query

Implementation

void updateCache<T>(String queryKey, T data, DateTime timestamp) {
  final query = _queries[queryKey];
  // Allow caching even without a query instance (e.g. prefetch)
  // Default to 5 minutes if no query/config available
  final cacheTime = query?.config.cacheTime ?? const Duration(minutes: 5);

  _setCacheEntry(queryKey, data, timestamp, cacheTime);

  // Persist if enabled
  if (query != null && query.config.persist) {
    _persistQuery(
        queryKey, data, timestamp, query.config as ZenQueryConfig<T>);
  }
}