public async Task Pipeline_can_be_replayed() { string KeySquared = Key + Key; Assert.That(await RedisAsync.GetValueAsync(Key), Is.Null); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.Null); await using var pipeline = RedisAsync.CreatePipeline(); pipeline.QueueCommand(r => r.IncrementValueAsync(Key)); pipeline.QueueCommand(r => r.IncrementValueAsync(KeySquared)); await pipeline.FlushAsync(); Assert.That(await RedisAsync.GetValueAsync(Key), Is.EqualTo("1")); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.EqualTo("1")); await NativeAsync.DelAsync(Key); await NativeAsync.DelAsync(KeySquared); Assert.That(await RedisAsync.GetValueAsync(Key), Is.Null); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.Null); await pipeline.ReplayAsync(); await pipeline.DisposeAsync(); Assert.That(await RedisAsync.GetValueAsync(Key), Is.EqualTo("1")); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.EqualTo("1")); }
public virtual async Task TearDown() { foreach (var t in await RedisAsync.SearchKeysAsync(RedisRaw.NamespacePrefix + "*")) { await NativeAsync.DelAsync(t); } }
public async Task Transaction_can_be_replayed() { string KeySquared = Key + Key; Assert.That(await RedisAsync.GetValueAsync(Key), Is.Null); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.Null); await using var trans = await RedisAsync.CreateTransactionAsync(); trans.QueueCommand(r => r.IncrementValueAsync(Key)); trans.QueueCommand(r => r.IncrementValueAsync(KeySquared)); await trans.CommitAsync(); Assert.That(await RedisAsync.GetValueAsync(Key), Is.EqualTo("1")); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.EqualTo("1")); await NativeAsync.DelAsync(Key); await NativeAsync.DelAsync(KeySquared); Assert.That(await RedisAsync.GetValueAsync(Key), Is.Null); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.Null); await trans.ReplayAsync(); await trans.DisposeAsync(); Assert.That(await RedisAsync.GetValueAsync(Key), Is.EqualTo("1")); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.EqualTo("1")); }
public async Task Transaction_can_issue_watch() { await NativeAsync.DelAsync(Key); Assert.That(await RedisAsync.GetValueAsync(Key), Is.Null); string KeySquared = Key + Key; await NativeAsync.DelAsync(KeySquared); await RedisAsync.WatchAsync(new[] { Key, KeySquared }); await RedisAsync.SetAsync(Key, 7); await using (var trans = await RedisAsync.CreateTransactionAsync()) { trans.QueueCommand(r => r.SetAsync(Key, 1).AsValueTask()); trans.QueueCommand(r => r.SetAsync(KeySquared, 2).AsValueTask()); await trans.CommitAsync(); } Assert.That(await RedisAsync.GetValueAsync(Key), Is.EqualTo("7")); Assert.That(await RedisAsync.GetValueAsync(KeySquared), Is.Null); }