clear method
Clears the cache
Implementation
Future<void> clear() async {
await _ensureInitialized();
try {
// Clear memory cache
_memoryCache.clear();
_memoryCacheSize = 0;
// Clear disk cache
if (await _diskCacheDir.exists()) {
final files = await _diskCacheDir.list().toList();
for (final file in files) {
await file.delete();
}
}
logger?.info('Cache cleared');
} catch (e) {
logger?.error('Error clearing cache: $e');
rethrow;
}
}