Skip to content

Commit

Permalink
Add support for queuing commands within a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Jun 19, 2024
1 parent 047d18e commit c21030b
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions course-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3458,7 +3458,32 @@ stages:
name: "Queueing commands"
difficulty: medium
description_md: |
**🚧 We're still working on instructions for this stage**. You can find notes on how the tester works below.
In this stage, you'll add support for queuing commands within a transaction.
### Queuing commands
After [MULTI](https://redis.io/docs/latest/commands/multi/) is executed, any further commands
from a connection are queued until [EXEC](https://redis.io/docs/latest/commands/exec/) is executed.
The response to all of these commands is `+QUEUED\r\n` (That's `QUEUED` encoded as a [Simple String](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-strings)).
Example:
```bash
$ redis-cli
> MULTI
OK
> SET foo 41
QUEUED
> INCR foo
QUEUED
... (and so on, until EXEC is executed)
```
When commands are queued, they should not be executed or alter the database in any way.
In the example above, until `EXEC` is executed, the key `foo` will not exist.
### Tests
Expand All @@ -3471,17 +3496,18 @@ stages:
The tester will then connect to your server as a Redis client, and send multiple commands using the same connection:
```bash
$ redis-cli MULTI
> SET foo 41
> INCR foo
$ redis-cli
> MULTI
> SET foo 41 (expecting "+QUEUED\r\n")
> INCR foo (expecting "+QUEUED\r\n")
```
The tester will then create another connection to your master as a Redis client, and send a single command:
Since these commands were only "queued", the key `foo` should not exist yet. The tester will verify this by creating
another connection and sending this command:
```bash
$ redis-cli GET foo
$ redis-cli GET foo (expecting `$-1\r\n` as the response)
```
marketing_md: |
In this stage, you'll implement queueing commands to a transaction.
Expand Down

0 comments on commit c21030b

Please sign in to comment.