getCacheStats method

Future<Map<String, dynamic>> getCacheStats()

Get cache statistics

Returns information about browser cache usage.

Implementation

Future<Map<String, dynamic>> getCacheStats() async {
  await _ensureInitialized();

  try {
    final registry = ServiceRegistry.instance;
    final downloadService = registry.downloadService as WebDownloadService;
    final cacheService = downloadService.cacheService;

    final quota = await cacheService.getStorageQuota();
    final urls = await cacheService.getCachedUrls();

    return {
      'cachedUrls': urls.length,
      'storageUsage': quota.usage,
      'storageQuota': quota.quota,
      'usagePercent': quota.usagePercent,
      'availableBytes': quota.available,
    };
  } catch (e) {
    debugPrint('[WebModelManager] ❌ getCacheStats failed: $e');
    return {
      'cachedUrls': 0,
      'storageUsage': 0,
      'storageQuota': 0,
      'usagePercent': 0.0,
      'availableBytes': 0,
    };
  }
}