.NET StackExchangeRedis 和 Batch 的执行顺序不能保证?

.NET StackExchangeRedis and order of execution with Batch not guaranteed?

我正在审查以下代码,它试图:

{
    var batch = database.CreateBatch();

    var tasks = new Task[]
    {
        batch.SetAddAsync(key, value, flags),
        batch.KeyExpireAsync(key, expiry, flags)
    };

    batch.Execute();

    await Task.WhenAll(tasks)
}

在一个 redis 中完成这一切 Batch

我的印象是,当涉及到批处理时,您不能假定顺序,更不用说 async/await 中的多个任务了。

因此,可能会出现以下顺序:

我希望但不希望订单得到保证,意思是..它会尽可能快地并行处理。

所以 - 我的理解是正确的还是错误的?

保证顺序,不会并行操作

转述其中一位作者 (@Mark-Gravell):

批处理的作用是推迟一组操作并确保它们彼此相邻地发送到单个连接,因此该多路复用器上的其他线程不会在中间获得命令。

更新

@mjwills 已经提到了 . Also this unit test assumes so. Also you can verify that on the RedisBridge.cs code. Even in a cluster, since you are issuing both commands to the same key, both will go to the same node, and they are internally pushed to/pulled from a Queue.