From b247b8f46d00588acfdb3fafea0447bdb3d906c5 Mon Sep 17 00:00:00 2001 From: Paul Kuruvilla Date: Wed, 19 Jun 2024 17:32:01 +0100 Subject: [PATCH] Add support for the DISCARD command in course-definition.yml --- course-definition.yml | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/course-definition.yml b/course-definition.yml index cd03b57f..ad1f222b 100644 --- a/course-definition.yml +++ b/course-definition.yml @@ -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 @@ -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: |