// https://redis.io/commands/hrandfield/
// HRANDFIELD key [count [WITHVALUES]]
RedisResult redisResult = await database.ExecuteAsync("HRANDFIELD", key, 10, "WITHVALUES");
Dictionary<string, string> results = new Dictionary<string, string>();
RedisValue[] redisResults = (RedisValue[])redisResult;
for (int i = 0; i < redisResults.Length; i += 2)
{
results[redisResults[i]] = redisResults[i + 1];
}
Console.WriteLine(JsonConvert.SerializeObject(results));
注:HRANDFIELD
需要redis版本至少6.2.0