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.

MULTI

Last updated
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.

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
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379(TX)> INCR orders
QUEUED
127.0.0.1:6379(TX)> LPUSH recent order:1001
QUEUED
127.0.0.1:6379(TX)> EXEC
1) (integer) 1
2) (integer) 1

Same as Redis 7 and Valkey 8.

EXEC, DISCARD, WATCH, UNWATCH