isMappingAvailableForBulk method

  1. @override
FutureOr<Map<String, bool>> isMappingAvailableForBulk(
  1. Iterable<String> digests
)
override

Checks if the mapping is available for the given digests in bulk.

Implementation

@override
FutureOr<Map<String, bool>> isMappingAvailableForBulk(
  Iterable<String> digests,
) async {
  final transaction = await _command.multi();

  final futures = <String, Future<dynamic>>{};

  for (final digest in digests) {
    futures[digest] = transaction.get(digest);
  }

  late Map<String, String?> data;

  final response = await transaction.exec();
  if (response.toString() == 'OK') {
    data = await _waitMapFutures(futures);

    _cache.clear();
    for (var entry in data.entries) {
      if (entry.value != null) _cache[entry.key] = entry.value!;
    }
  } else {
    throw Exception(
      '$_tag: isMappingAvailableForBulk: Redis Error $response',
    );
  }

  return data.map((key, value) => MapEntry(key, value != null));
}