Recall & Review
beginner
What does the
DISCARD command do in Redis transactions?It cancels all commands queued in the current transaction and exits the transaction without executing any of them.
Click to reveal answer
beginner
When should you use
DISCARD in Redis?Use
DISCARD when you want to abort a transaction because something went wrong or you no longer want to execute the queued commands.Click to reveal answer
intermediate
What happens if you run
DISCARD without starting a transaction with MULTI?Redis will return an error because
DISCARD only works inside a transaction block started by MULTI.Click to reveal answer
intermediate
How does
DISCARD affect the Redis command queue?It clears the queue of commands that were added after
MULTI and before EXEC, so none of those commands run.Click to reveal answer
beginner
Compare
DISCARD and EXEC in Redis transactions.EXEC runs all queued commands in the transaction, while DISCARD cancels them all without running anything.Click to reveal answer
What does the Redis
DISCARD command do?✗ Incorrect
DISCARD cancels all commands queued after MULTI and aborts the transaction.
When can you use
DISCARD in Redis?✗ Incorrect
DISCARD works only inside a transaction block, after MULTI and before EXEC.
What happens if you run
DISCARD without starting a transaction?✗ Incorrect
DISCARD requires a transaction started by MULTI. Without it, Redis returns an error.
Which command in Redis actually runs the queued commands in a transaction?
✗ Incorrect
EXEC executes all commands queued after MULTI.
If you want to cancel a transaction in Redis, which command should you use?
✗ Incorrect
DISCARD aborts the transaction and clears the queued commands.
Explain how the
DISCARD command works in Redis transactions and when you would use it.Think about stopping a group of commands before they run.
You got /4 concepts.
Describe the difference between
EXEC and DISCARD in Redis transactions.One means go, the other means stop.
You got /4 concepts.