get method

  1. @override
Future<Uint8List?> get(
  1. String sha256
)
override

Returns the bytes for sha256, or null if absent.

On a successful hit, implementations MUST update the blob's BlobDescriptor.lastAccessedAt to the current time so that LRU-based eviction can rely on it.

Implementation

@override
Future<Uint8List?> get(String sha256) async {
  if (!_keyPattern.hasMatch(sha256)) return null;
  final db = _required;
  final Uint8List bytes;
  try {
    bytes = await _blobFile(sha256).readAsBytes();
  } on PathNotFoundException {
    return null;
  }
  final updated = await _meta.record(sha256).update(db, {
    'lastAccessedAt': DateTime.now().toUtc().millisecondsSinceEpoch,
  });
  return updated == null ? null : bytes;
}