Skip to content

Commit

Permalink
Improving text for transactional write
Browse files Browse the repository at this point in the history
Signed-off-by: P K Navin Shrinivas <[email protected]>
  • Loading branch information
NavinShrinivas committed Oct 1, 2024
1 parent ae42f0c commit 7444fc5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions content/en/docs/v3.5/tutorials/how-to-transactional-write.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,28 @@ del user1
failure requests (get, put, delete):
put user1 good
```

### Transaction for multiple writes

A transaction is an atomic If/Then/Else construct over the key-value store. It provides a primitive for grouping requests together in atomic blocks (i.e., then/else) whose execution is guarded (i.e., if) based on the contents of the key-value store. Transactions can be used for protecting keys from unintended concurrent updates, building compare-and-swap operations, and developing higher-level concurrency control. However, modifications to the same key multiple times within a single transaction are forbidden.

```shell
etcdctl --endpoints=$ENDPOINTS put user1 bad

etcdctl --endpoints=$ENDPOINTS txn --interactive
compares:
value("user1") = "bad"

success requests (get, put, del):
put user test
put user2 testing3
get user1

failure requests (get, put, del):
put user1 bad
```

<!--need to add gif showing the examples for multiple writes and failing when written to same key-->



0 comments on commit 7444fc5

Please sign in to comment.