2881099 / FreeRedis

🦄 FreeRedis is .NET40+ redis client. supports cluster, sentinel, master-slave, pub-sub, lua, pipeline, transaction, streams, client-side-caching, and pooling.
MIT License
924 stars 165 forks source link

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

Closed tky753 closed 3 weeks ago

tky753 commented 1 year ago

示例

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

管道也会卡死

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

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

因为事务、管道不会马上返回结果,只有 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;

管道同理。

tky753 commented 1 year ago

EndPipeExec是否应该提供异步方法

2881099 commented 1 year ago

漏掉了,有空补

Cyaim commented 3 weeks ago

现在还是卡死,且莫得异步方法

2881099 commented 3 weeks ago

异步管道和事务不是你们这样用。仔细回复说明。