read<T> method
Future<KachePersistenceRead<T> ?>
read<T>({
- required KacheKey key,
- required KachePersistenceBinding<
T> binding,
override
Reads the entry for key, or returns null when no entry exists.
The binding describes backend-specific handling for T. Implementations
should call KachePersistenceBinding.ensureBackend before using it.
Storage access failures use KachePersistenceStage.backend, initial value
interpretation failures use KachePersistenceStage.decode, and format
migration or deferred maintenance failures use
KachePersistenceStage.migration.
Implementation
@override
Future<KachePersistenceRead<T>?> read<T>({
required KacheKey key,
required KachePersistenceBinding<T> binding,
}) async {
_ensureOpen(KachePersistenceOperation.read);
binding.ensureBackend(this);
final record = _entries[key.storageKey];
if (record == null) {
return null;
}
_ensureCompatible<T>(
record: record,
binding: binding,
operation: KachePersistenceOperation.read,
);
return KachePersistenceRead<T>(
entry: KachePersistedEntry<T>(
data: record.data as T,
metadata: record.metadata,
),
);
}