DISCARD(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’… DISCARD β€” the "nvm bestie, forget it" command

okay so real talk, discard is a valkey command and it does exactly one thing: it throws your whole transaction in the trash and pretends it never happened. no cap.


✨ SYNOPSIS ✨

DISCARD

that's it. that's the whole vibe. no args, no options, no notes. she's low maintenance. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

DISCARD flushes all previously queued commands in a transaction and restores the connection state to normal.

so like. you were building a whole thing with MULTI and queueing up commands like a good little main character, and then you changed your mind? iconic. DISCARD empties the queue, nothing runs, and your connection goes back to its regular non-transaction self. we love a clean slate. ✨

If WATCH was used, DISCARD unwatches all keys watched by the connection.

translation: if you were keeping an eye on some keys πŸ‘€, that watch is cancelled too. no lingering parasocial key relationships here. 🫢


🌸 REPLY 🌸

valkey-protocol(7) Simple string reply: OK.

it says OK and means it. fr fr.


πŸŽ€ COMPLEXITY πŸŽ€

O(N), when N is the number of queued commands

so the more nonsense you queued up, the longer it takes to throw away. make it make sense, but that's the math. πŸ’€


πŸ”₯ ACL CATEGORIES πŸ”₯

  • @fast
  • @transaction

🌈 HISTORY 🌈

  • Available since: 2.0.0

she's been serving since 2.0.0. a legend. a pioneer. periodt.


πŸ‘‘ SEE ALSO πŸ‘‘


not me reminding you that if you don't DISCARD, those queued commands are still sitting there waiting. vibe check your transactions, bestie. πŸ’–

valkey command manual, version 9.0.0, dated 2025-10-21 β€” mwah, go slay your transactions, iykyk πŸ§šπŸ’œ

πŸ“¦ where this page comes from