whereKeyStartsWith method

  1. @override
Future<Map<String, dynamic>> whereKeyStartsWith(
  1. String prefix
)

Implementation

@override
Future<Map<String, dynamic>> whereKeyStartsWith(String prefix) async {
  final keys = await Command(_connection).send_object(['KEYS', '$prefix*']);

  final List values =
      await Command(_connection).send_object(['MGET', ...keys]);
  final results = await values.map((val) async {
    final index = values.indexOf(val);
    return {keys[index].toString(): jsonDecode(val)};
  }).wait;

  final Map<String, dynamic> r = {};
  for (final result in results) {
    r.addAll(result);
  }

  return r;
}