Skip to content

Commit

Permalink
Add support for the DISCARD command in course-definition.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Jun 19, 2024
1 parent cfdf812 commit b247b8f
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions course-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3576,7 +3576,30 @@ stages:
name: "The DISCARD command"
difficulty: easy
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 the DISCARD command.
### The DISCARD command
[DISCARD](https://redis.io/docs/latest/commands/discard/) is used to abort a transactions. It discards all commands queued in a transaction,
and returns `+OK\r\n`.
Example:
```bash
$ redis-cli
> MULTI
OK
> SET foo 41
QUEUED
> DISCARD
OK
> DISCARD
(error) ERR DISCARD without MULTI
```
In the above example, note that the first `DISCARD` returns `OK`, but the second `DISCARD` returns an error since the transaction was aborted.
### DISCARD
### Tests
Expand All @@ -3589,13 +3612,13 @@ 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
> DISCARD
> GET foo
> GET bar
> DISCARD
$ redis-cli
> MULTI
> SET foo 41 (expecting "+QUEUED\r\n")
> INCR foo (expecting "+QUEUED\r\n")
> DISCARD (expecting "+OK\r\n")
> GET foo (expecting "$-1\r\n" as the response)
> DISCARD (expecting "-ERR DISCARD without MULTI\r\n" as the response)
```
marketing_md: |
Expand Down

0 comments on commit b247b8f

Please sign in to comment.