Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

DISCARD

Last updated
DISCARD
Group
Transactions
Complexity
O(N) where N is the number of queued commands
Arity
1 (exactly, counting the command name)
Flags
fast
HotKV Cloud
All plans
On-Premise
no license needed

DISCARD throws away every command queued since MULTI, ends the transaction without running anything, and unwatches all keys watched with WATCH.

Case RESP2 RESP3
The transaction was discarded Simple string OK Simple string OK
No MULTI was sent Error ERR DISCARD without MULTI Error
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379(TX)> DEL important
QUEUED
127.0.0.1:6379(TX)> DISCARD
OK
127.0.0.1:6379> EXISTS important
(integer) 1

Same as Redis 7 and Valkey 8.

MULTI, EXEC, UNWATCH