remove method

  1. @override
Future<FileSystemEntity?> remove(
  1. String key
)
override

Removes the entry for the specified key from the cache, if it exists.

Returns the removed file, or null if the key was not present. Updates the cache size and deletes the file from disk. The operation is thread-safe.

Implementation

@override
Future<FileSystemEntity?> remove(String key) async {
  assert(key.isNotEmpty, 'key must not be empty');
  return await lock.synchronized(() async {
    final FileSystemEntity? previous = map.remove(key);
    if (previous != null) {
      size -= (await previous.stat()).size;
      await previous.delete();
    }
    return previous;
  });
}