FreeRedis
FreeRedis copied to clipboard
Multi(事务) 和 Pipe(管道) async 调用卡死
示例
using var cli = new RedisClient("xxx,password=xxxxxx,defaultDatabase=xx");
using var tran = cli.Multi();
await tran.SetAsync("key", "{}"); //卡在这一句
tran.Exec();
管道也会卡死
using var pipe = cli.StartPipe();
await pipe.SetAsync("key", "{}"); //卡在这一句
pipe.EndPipe();
事务,管道异步不是这样用的。
因为事务、管道不会马上返回结果,只有 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;
管道同理。
那EndPipe和Exec是否应该提供异步方法
漏掉了,有空补