问题是,我想在管道刷新后得到queuecommand的结果,但是我不知道如何通过使用servicestack redis来获得结果
例如:
pipeline.QueueCommand(r => r.Get<string>("foo"));
pipeline.Flush();
我应该在哪里获得“foo”的结果,以便我可以将结果传回给其他人?
答案 0 :(得分:3)
阅读有关GitHub上交易的the Wiki Page。
特别是这个例子
int callbackResult;
using (var trans = redis.CreateTransaction())
{
trans.QueueCommand(r => r.Increment("key"));
trans.QueueCommand(r => r.Increment("key"), i => callbackResult = i);
trans.Commit();
}
//The value of "key" is incremented twice. The latest value of which is also stored in 'callbackResult'.
有一个带回调的虚方法,可以给你结果。
public virtual void QueueCommand(Func<IRedisClient, string> command, Action<string> onSuccessCallback, Action<Exception> onErrorCallback).