Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 6 additions & 60 deletions content/develop/clients/dotnet/transpipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,8 @@ versions of the standard command methods
buffered in the pipeline and only execute when you call the `Execute()`
method on the pipeline object.

<!-- < clients-example pipe_trans_tutorial basic_pipe "C#" >}}
< /clients-example >}} -->

```csharp
var pipeline = new Pipeline(db);

for (int i = 0; i < 5; i++) {
pipeline.Db.StringSetAsync($"seat:{i}", $"#{i}");
}
pipeline.Execute();

var resp1 = db.StringGet("seat:0");
Console.WriteLine(resp1); // >>> #0

var resp2 = db.StringGet("seat:3");
Console.WriteLine(resp2); // >>> #3

var resp3 = db.StringGet("seat:4");
Console.WriteLine(resp2); // >>> #4
```
{{< clients-example pipe_trans_tutorial basic_pipe "C#" >}}
{{< /clients-example >}}

## Execute a transaction

Expand All @@ -65,27 +47,8 @@ instance of the `Transaction` class, call async command methods
on that object, and then call the transaction object's
`Execute()` method to execute it.

<!-- < clients-example pipe_trans_tutorial basic_trans "C#" >}}
< /clients-example >}}-->

```csharp
var trans = new Transaction(db);

trans.Db.StringIncrementAsync("counter:1", 1);
trans.Db.StringIncrementAsync("counter:2", 2);
trans.Db.StringIncrementAsync("counter:3", 3);

trans.Execute();

var resp4 = db.StringGet("counter:1");
Console.WriteLine(resp4); // >>> 1

var resp5 = db.StringGet("counter:2");
Console.WriteLine(resp5); // >>> 2

var resp6 = db.StringGet("counter:3");
Console.WriteLine(resp6); // >>> 3
```
{{< clients-example pipe_trans_tutorial basic_trans "C#" >}}
{{< /clients-example >}}

## Watch keys for changes

Expand Down Expand Up @@ -114,25 +77,8 @@ For example, the `KeyNotExists` condition aborts the transaction
if a specified key exists or is added by another client while the
transaction executes:

<!-- < clients-example pipe_trans_tutorial trans_watch "C#" >}}
< /clients-example >}} -->

```csharp
var watchedTrans = new Transaction(db);

watchedTrans.AddCondition(Condition.KeyNotExists("customer:39182"));

watchedTrans.Db.HashSetAsync(
"customer:39182",
new HashEntry[]{
new HashEntry("name", "David"),
new HashEntry("age", "27")
}
);

bool succeeded = watchedTrans.Execute();
Console.WriteLine(succeeded); // >>> true
```
{{< clients-example pipe_trans_tutorial trans_watch "C#" >}}
{{< /clients-example >}}

You can also use a `When` condition on certain individual commands to
specify that they only execute when a certain condition holds
Expand Down