zrange method

Future<Map<String, double>> zrange(
  1. String key,
  2. int start,
  3. int stop
)

zrange

Implementation

Future<Map<String, double>> zrange(String key, int start, int stop) async {
  return await _runWithRetryNew(() async {
    final result =
        (await RespCommandsTier1(_client!).zrange(key, start, stop))
            .toArray()
            .payload;

    if (result != null) {
      final Map<String, double> memberScores = {};

      for (int i = 0; i < result.length; i += 2) {
        final member = result[i].toBulkString().payload;
        final score = result[i + 1].toBulkString().payload;

        if (member != null && score != null) {
          memberScores[member] = double.parse(score);
        }
      }

      return memberScores;
    }
    return {};
  });
}