Skip to content

Commit f78b8bf

Browse files
authored
Merge pull request codecrafters-io#226 from codecrafters-io/add-transactions-docs
Add support for multiple concurrent transactions in stage "Multiple transactions".
2 parents fa85c8e + d797e9d commit f78b8bf

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

course-definition.yml

+47-1
Original file line numberDiff line numberDiff line change
@@ -3712,7 +3712,53 @@ stages:
37123712
name: "Multiple transactions"
37133713
difficulty: medium
37143714
description_md: |
3715-
**🚧 We're still working on instructions for this stage**. You can find notes on how the tester works below.
3715+
In this stage, you'll add support for multiple concurrent transactions.
3716+
3717+
### Multiple transactions
3718+
3719+
There can be multiple transactions open (i.e. `MULTI` has been called, but `EXEC` has not been called yet) at the same time. Each
3720+
transaction gets its own command queue.
3721+
3722+
For example, say you started transaction 1 from one connection:
3723+
3724+
```bash
3725+
$ redis-cli
3726+
> MULTI
3727+
OK
3728+
> SET foo 41
3729+
QUEUED
3730+
> INCR foo
3731+
QUEUED
3732+
```
3733+
3734+
and started transaction 2 from another connection:
3735+
3736+
```bash
3737+
$ redis-cli
3738+
> MULTI
3739+
OK
3740+
> INCR foo
3741+
QUEUED
3742+
```
3743+
3744+
If you then run `EXEC` in transaction 1, you should see the following:
3745+
3746+
```bash
3747+
> EXEC
3748+
1) OK
3749+
2) (integer) 42
3750+
```
3751+
3752+
`OK` is the response to `SET foo 41`, and `42` is the response to `INCR foo`.
3753+
3754+
And for transaction 2, running `EXEC` should return:
3755+
3756+
```bash
3757+
> EXEC
3758+
1) (integer) 43
3759+
```
3760+
3761+
43 is the response to `INCR foo`. The key `foo` was updated to `42` by transaction 1, and `INCR foo` further increments it to `43`.
37163762
37173763
### Tests
37183764

0 commit comments

Comments
 (0)