Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redis · Command

MULTI

MULTI starts a Redis transaction and queues later commands on the current connection. EXEC runs the queued commands atomically, while DISCARD cancels them.

Since
1.2.0

How it works

MULTI switches the current connection into transaction mode. Commands sent afterward are queued rather than run immediately, and EXEC later runs the queued commands as one atomic batch; DISCARD can instead clear the queue and leave transaction mode.

Syntax

MULTI

Returns

Simple string reply: OK.

Key points

  • MULTI begins a transaction on the current client connection.
  • Commands after MULTI wait in a queue and are executed together when EXEC is called.
  • A successful MULTI command acknowledges entry into transaction mode with OK.
  • EXEC is the commit point that causes Redis to run the queued commands.
  • The command has no client API method signature documented on its command-reference page.

Common mistakes

  • Clustered deployments can impose different transaction behavior, so verify the multi-key transaction constraints for the topology in use.
  • Do not expect queued commands to return their normal results before EXEC; their immediate replies indicate that they were queued.
  • Use DISCARD to abandon the queued commands instead of executing them.

Example: Queue and execute a transaction

MULTI
SET cache:user:42 "Ada"
INCR stats:users
EXEC

Starts a transaction, queues two commands, then executes them atomically with EXEC.

When to use it

Atomic grouped updates

Update several related keys as one uninterrupted operation.

Transaction batching

Batch commands that must be committed together.

Optimistic concurrency control

Pair with WATCH when writes depend on a prior read.

Interview questions

QWhat does MULTI do?

MULTI marks the beginning of a Redis transaction and changes the connection into transaction mode. Subsequent commands are queued, and EXEC executes them as a group.

Follow-up: How can a client cancel the transaction? Send DISCARD; it removes the queued commands and restores the connection to normal mode.

QWhat replies should a client expect after MULTI?

MULTI itself returns the simple string reply OK. Commands issued after MULTI normally return QUEUED because Redis schedules them for execution at EXEC.

Follow-up: When are the commands' actual results available? EXEC returns the results after the queued commands run.

QWhat are MULTI's syntax, complexity, and introduction version?

MULTI has O(1) time complexity and was introduced in Redis Open Source 1.2.0. Its syntax is simply MULTI, with no arguments.

Follow-up: Which related commands complete or cancel the transaction? EXEC commits the queued commands, while DISCARD aborts them.

  • EXEC
  • DISCARD
  • WATCH

Source: MULTI | Docs - Redis. Checked 2026-10-16.