cacheMoviesForCategory method

Future<void> cacheMoviesForCategory(
  1. CacheCategory category,
  2. List<Movie> movies
)

Cache movies for a specific category.

Implementation

Future<void> cacheMoviesForCategory(
  CacheCategory category,
  List<Movie> movies,
) async {
  await _ensureInitialized();
  try {
    // Store movies as a list.

    await _movieBox!.put(category.value, movies);

    // Store timestamp for cache expiration.

    await _timestampBox!.put(category.value, DateTime.now());
  } catch (e) {
    debugPrint('Error caching movies for ${category.value}: $e');
    rethrow;
  }
}