FreeRedis icon indicating copy to clipboard operation
FreeRedis copied to clipboard

Multi(事务) 和 Pipe(管道) async 调用卡死

Open tky753 opened this issue 2 years ago • 4 comments

示例

using var cli = new RedisClient("xxx,password=xxxxxx,defaultDatabase=xx");
using var tran = cli.Multi();
await tran.SetAsync("key", "{}");   //卡在这一句
tran.Exec();

tky753 avatar Jan 10 '23 05:01 tky753

管道也会卡死

using var pipe = cli.StartPipe();
await pipe.SetAsync("key", "{}");   //卡在这一句
pipe.EndPipe();

tky753 avatar Jan 10 '23 06:01 tky753

事务,管道异步不是这样用的。

因为事务、管道不会马上返回结果,只有 Exec、EndPipe 时才会返回结果,所以此时等待没有意义。

Task<int> task1 = null;

using var cli = new RedisClient("xxx,password=xxxxxx,defaultDatabase=xx");
using var tran = cli.Multi();
task1 = tran.SetAsync("key", "{}");   //卡在这一句
tran.Exec();

var result = task1.Result;

管道同理。

2881099 avatar Jan 10 '23 09:01 2881099

EndPipeExec是否应该提供异步方法

tky753 avatar Jan 10 '23 09:01 tky753

漏掉了,有空补

2881099 avatar Jan 10 '23 09:01 2881099