Easy Tutorial
❮ Redis Pipelining Hashes Hdel ❯

Redis Multi Command

Redis Transactions

The Redis Multi command is used to mark the beginning of a transaction block.

Multiple commands within the transaction block are queued in order and are executed atomically by the EXEC command.

Syntax

The basic syntax for the redis Multi command is as follows:

redis 127.0.0.1:6379> MULTI

Available Versions

= 1.2.0

Return Value

Always returns OK.

Example

redis 127.0.0.1:6379> MULTI            # Marks the start of the transaction
OK

redis 127.0.0.1:6379> INCR user_id     # Multiple commands are queued in order
QUEUED

redis 127.0.0.1:6379> INCR user_id
QUEUED

redis 127.0.0.1:6379> INCR user_id
QUEUED

redis 127.0.0.1:6379> PING
QUEUED

redis 127.0.0.1:6379> EXEC             # Executes the queued commands
1) (integer) 1
2) (integer) 2
3) (integer) 3
4) PONG

Redis Transactions

❮ Redis Pipelining Hashes Hdel ❯