remove method

  1. @override
Future remove(
  1. String? correlationId,
  2. String? key
)
override

Removes a value from the cache by its key.

  • correlationId (optional) transaction id to trace execution through call chain.
  • key a unique value key. Return Future that receives an null for success Throws error

Implementation

@override
Future<dynamic> remove(String? correlationId, String? key) async {
  if (key == null) {
    var err = Exception('Key cannot be null');
    throw err;
  }

  // Get the entry
  CacheEntry? entry = _cache[key]; //.cast<CacheEntry>();

  // Remove entry from the cache
  if (entry != null) {
    _cache.remove(key);
    _count--;
  }
  return null;
}