forget method
Removes a value from the cache by its key.
Deletes the cached item associated with the key if it exists.
If the key does not exist, this operation should be a no-op (no exception thrown).
Throws an exception if the key is null or empty.
- Parameters:
key: A non-null, non-empty string representing the cache key.
Implementation
@override
Future<void> forget(String key) async {
if (key.isEmpty) {
throw ArgumentError('Cache key cannot be empty');
}
if (_store.remove(key) != null) {
_stats.deletions++;
}
}