getCacheMetadata method

Future<Map<String, dynamic>?> getCacheMetadata(
  1. CacheCategory category
)

Get cache metadata for a category.

Implementation

Future<Map<String, dynamic>?> getCacheMetadata(CacheCategory category) async {
  await _ensureInitialized();
  try {
    final timestamp = _timestampBox!.get(category.value);
    final movies = await getCachedMoviesForCategory(category);

    if (timestamp == null || movies == null) return null;

    final age = DateTime.now().difference(timestamp);
    final isValid = await isCacheValid(category);

    return {
      'category': category.value,
      'lastUpdated': timestamp,
      'movieCount': movies.length,
      'isValid': isValid,
      'age': age,
    };
  } catch (e) {
    debugPrint('Error getting cache metadata for ${category.value}: $e');
    return null;
  }
}