remove method
Deletes the durable record for id.
Removing an absent id succeeds. When ifVersion is given, a
stored row that does not match it throws MemoryConflict and is
left in place.
Implementation
@override
Future<void> remove(String id, {MemoryVersion? ifVersion}) {
checkId(id);
return _lifecycle.run(() => _serializer.run(id, () async {
await _checkCaseCollision(id);
final file = _fileFor(id);
if (!await file.exists()) return;
if (ifVersion != null) {
final existing = await _readEnvelopeFile(file);
if (existing != null &&
!_isExpired(existing) &&
(existing.revision != ifVersion.revision ||
existing.generation != ifVersion.generation)) {
throw MemoryConflict(expected: ifVersion, stored: existing);
}
}
await _delete(file);
_nameIndex.remove('$id.json');
}));
}