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 {
  await _ensureInitialized();

  final metadata = _metadataCache[key];
  if (metadata == null) return false;

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

  // Verify data exists in SharedPreferences
  return _prefs!.containsKey('$_keyPrefix$key');
}