getCacheStats method

Map<String, dynamic> getCacheStats()

Get cache statistics for debugging.

Implementation

Map<String, dynamic> getCacheStats() {
  final now = DateTime.now();
  return {
    'toWatch': {
      'cached': _cachedToWatch != null,
      'count': _cachedToWatch?.length ?? 0,
      'age': _toWatchCacheTime != null
          ? now.difference(_toWatchCacheTime!).inMinutes
          : null,
      'valid': _cachedToWatch != null &&
          _toWatchCacheTime != null &&
          now.difference(_toWatchCacheTime!) < _userDataTtl,
    },
    'watched': {
      'cached': _cachedWatched != null,
      'count': _cachedWatched?.length ?? 0,
      'age': _watchedCacheTime != null
          ? now.difference(_watchedCacheTime!).inMinutes
          : null,
      'valid': _cachedWatched != null &&
          _watchedCacheTime != null &&
          now.difference(_watchedCacheTime!) < _userDataTtl,
    },
  };
}