// Author: fengshengxiong
// Date: 2024/6/25
// Description: 自定义音乐缓存管理器

import 'package:flutter_cache_manager/flutter_cache_manager.dart';

class MusicCacheManager {
  static const key = 'musicCacheKey';
  static CacheManager instance = CacheManager(
    Config(
      key,
      stalePeriod: const Duration(days: 7),
      maxNrOfCacheObjects: 30,
    ),
  );

  static String getCacheKey(String videoId) {
    return 'music_$videoId';
  }

  /// 检查是否有缓存
  static Future<FileInfo?> checkCache(String videoId) async {
    return await instance.getFileFromCache(getCacheKey(videoId));
  }
}