pull method

  1. @override
Future pull(
  1. dynamic key, [
  2. dynamic defaultValue
])
override

Retrieves an item from the cache and deletes it.

If the item is not found, returns the defaultValue.

  • key: The key of the item to retrieve.
  • defaultValue: The value to return if the item is not found.

Returns the cached item or the defaultValue if the item is not found.

Implementation

@override
Future<dynamic> pull(dynamic key, [dynamic defaultValue]) async {
  final keyString = key is String ? key : key.toString();
  final namespaced = await _namespaced(keyString);
  final value = await store.get(namespaced);
  await store.forget(namespaced);
  return value ?? defaultValue;
}