containsKey method

  1. @override
Future<bool> containsKey(
  1. String key
)
override

Checks if a valid (non-expired) value exists for the given identifier.

key - Unique identifier of the value

Returns true if it exists and hasn't expired, false otherwise

Implementation

@override
Future<bool> containsKey(String key) async {
  final entry = _cache[key];

  if (entry == null) {
    return false;
  }

  // Check if expired
  if (entry.isExpired) {
    await remove(key);
    return false;
  }

  return true;
}