w3resource

Redis Transactions:MULTI

Redis MULTI command

Redis MULTI command is used to mark the start of a transaction block.

Here are some common uses and scenarios for the "MULTI" command:

  • Begin Transaction: Starts a transaction block, queuing commands for atomic execution with the EXEC command.
  • Batch Command Execution: Allows multiple commands to be queued and executed as a single unit, ensuring all commands are processed together.
  • Atomic Operations: Ensures that all commands within the transaction are executed atomically, or none at all if there is an error or if the transaction is aborted.
  • Concurrency Control: Helps manage concurrent operations by grouping commands to avoid partial updates and ensure data consistency.
  • Error Handling: Provides a way to handle errors by aborting the transaction with the DISCARD command if needed, preventing unintended changes.

Syntax:

MULTI 

Available since

1.2.0.

Return Value

Simple string reply: always OK.

Return Value Type

String

Example:

127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> INCR test
QUEUED
127.0.0.1:6379> INCR test1
QUEUED

Previous: EXEC
Next: UNWATCH



Follow us on Facebook and Twitter for latest update.