remove method

Result<CacheEntry<K, V, U>, CachetteError> remove(
  1. K key, {
  2. bool callOnEvict = false,
})

Removes an item with key from the cache.

Implementation

Result<CacheEntry<K, V, U>, CachetteError> remove(
  K key, {
  bool callOnEvict = false,
}) {
  if (!_items.containsKey(key)) {
    return Result.error(NotFoundError(key));
  }
  final result = _evict(key, callOnEvict: callOnEvict);
  if (!result.ok) {
    return Result.error(result.error!);
  }
  return Result.ok(result.object!);
}