MULTI
MULTI
- Group
- Transactions
- Complexity
- O(1)
- Arity
- 1 (exactly, counting the command name)
- Flags
- fast
- HotKV Cloud
- All plans
- On-Premise
- no license needed
MULTI starts a transaction on the connection. The commands you send after it
are not run right away: each is checked and queued, and the server replies
QUEUED. EXEC then runs the whole queue in order, with no
command from another client in between. DISCARD drops
the queue instead.
A command that is refused while queuing (an unknown command, the wrong number
of arguments, an ACL denial, a cluster redirect, or a command that is not
allowed in a transaction, such as SAVE, SHUTDOWN, SYNC or PSYNC)
replies with its error at once and makes the later EXEC fail with
EXECABORT. Errors a command hits while it runs inside EXEC do not stop the
other commands. WATCH, QUIT and RESET run immediately
even inside a transaction.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| The transaction started | Simple string OK |
Simple string OK |
| Already in a transaction | Error ERR MULTI calls can not be nested |
Error |
Examples
Section titled “Examples”127.0.0.1:6379> MULTIOK127.0.0.1:6379(TX)> INCR ordersQUEUED127.0.0.1:6379(TX)> LPUSH recent order:1001QUEUED127.0.0.1:6379(TX)> EXEC1) (integer) 12) (integer) 1Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.