Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 05a9a63

Browse files
committed
Add support for bool responses in BytesReadCommand queued transactions
1 parent 0f24c9c commit 05a9a63

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/ServiceStack.Redis/Pipeline/QueuedRedisOperation.cs

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public void ProcessResult()
128128
{
129129
OnSuccessIntCallback(result != null ? int.Parse(Encoding.UTF8.GetString(result)) : 0);
130130
}
131+
if (OnSuccessBoolCallback != null)
132+
{
133+
OnSuccessBoolCallback(result != null && Encoding.UTF8.GetString(result) == "OK");
134+
}
131135
}
132136
else if (StringReadCommand != null)
133137
{

tests/ServiceStack.Redis.Tests/RedisTransactionTests.cs

+17
Original file line numberDiff line numberDiff line change
@@ -403,5 +403,22 @@ public void Can_call_LUA_Script_in_transaction()
403403
Assert.That(result.Children[0].Text, Is.EqualTo("myval"));
404404
Assert.That(result.Children[1].Text, Is.EqualTo("myotherval"));
405405
}
406+
407+
[Test]
408+
public void Can_call_SetValueIfNotExists_in_transaction()
409+
{
410+
bool f = false;
411+
bool s = false;
412+
413+
using (var trans = Redis.CreateTransaction())
414+
{
415+
trans.QueueCommand(c => c.SetValueIfNotExists("foo", "blah"), r => f = r);
416+
trans.QueueCommand(c => c.SetValueIfNotExists("bar", "blah"), r => s = r);
417+
trans.Commit();
418+
}
419+
420+
Assert.That(f);
421+
Assert.That(s);
422+
}
406423
}
407424
}

0 commit comments

Comments
 (0)