public async Task<int> ExecuteIncrByAsync()
{
var rand = new Random(12345);
db.KeyDelete(IncrByKey, CommandFlags.FireAndForget);
int expected = 0;
for (int i = 0; i < COUNT; i++)
{
int x = rand.Next(50);
expected += x;
await db.StringIncrementAsync(IncrByKey, x, CommandFlags.FireAndForget).ConfigureAwait(false);
}
int actual = (int)await db.StringGetAsync(IncrByKey).ConfigureAwait(false);
if (actual != expected) throw new InvalidOperationException($"expected: {expected}, actual: {actual}");
return actual;
} |