0
0
Redisquery~5 mins

DISCARD to abort in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AStarts a new transaction
BExecutes all queued commands in a transaction
CCancels all queued commands in a transaction
DCommits changes to the database
When can you use DISCARD in Redis?
AOnly after <code>EXEC</code>
BOnly after <code>MULTI</code> and before <code>EXEC</code>
CAt any time
DOnly before <code>MULTI</code>
What happens if you run DISCARD without starting a transaction?
AIt clears the database
BIt does nothing
CIt starts a transaction
DIt returns an error
Which command in Redis actually runs the queued commands in a transaction?
AEXEC
BMULTI
CDISCARD
DWATCH
If you want to cancel a transaction in Redis, which command should you use?
ADISCARD
BEXEC
CMULTI
DSAVE
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.