hmget method

Future<Map<String, String?>> hmget(
  1. String key,
  2. List<String> fields
)

Returns the values associated with the specified fields in the hash stored at key.

For every field that does not exist in the hash, a nil value is returned. Because non-existing keys are treated as empty hashes, running HMGET against a non-existing key will return a list of nil values.

A map of values associated with the given fields, in the same order as they are requested.

Implementation

Future<Map<String, String?>> hmget(String key, List<String> fields) async {
  final result = (await tier1.hmget(key, fields)).toArray().payload;

  if (result != null) {
    final hash = <String, String?>{};
    for (var i = 0; i < fields.length; i++) {
      hash[fields[i]] = result[i].toBulkString().payload;
    }
    return hash;
  }
  return {};
}