remove method
Removes a cache entry
Implementation
Future<void> remove(String key) async {
await _ensureInitialized();
try {
// Remove from memory cache
final memoryEntry = _memoryCache[key];
if (memoryEntry != null) {
_memoryCacheSize -= memoryEntry.metadata.size;
_memoryCache.remove(key);
}
// Remove from disk cache
final diskFile = _getDiskCacheFile(key);
final diskMetaFile = _getDiskCacheMetaFile(key);
if (await diskFile.exists()) {
await diskFile.delete();
}
if (await diskMetaFile.exists()) {
await diskMetaFile.delete();
}
logger?.info('Removed cache entry $key');
} catch (e) {
logger?.error('Error removing cache entry $key: $e');
rethrow;
}
}