X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/b882056c93f3e3afe5fde9d62fb569ce30a76a76..b93fdb7bbb5b224efee06b36a12d454db975fed8:/doc/MultiExecCommand.html?ds=sidebyside diff --git a/doc/MultiExecCommand.html b/doc/MultiExecCommand.html index 65ec67a0..97f21482 100644 --- a/doc/MultiExecCommand.html +++ b/doc/MultiExecCommand.html @@ -32,12 +32,12 @@

COMMAND_1 ...

COMMAND_2 ...

COMMAND_N ...

-

EXEC or DISCARD

MULTI, EXEC, DISCARD and WATCH commands are the fundation of Redis Transactions. +

EXEC or DISCARD

MULTI, EXEC, DISCARD and WATCH commands are the foundation of Redis Transactions. A Redis Transaction allows the execution of a group of Redis commands in a single step, with two important guarantees:

Since Redis 2.1.0, it's also possible to add a further guarantee to the above two, in the form of optimistic locking of a set of keys in a way very similar to a CAS (check and set) operation. This is documented later in this manual page.

Usage

A Redis transaction is entered using the MULTI command. The command always replies with OK. At this point the user can issue multiple commands. Instead -to execute this commands Redis will "queue" them. All the commands are +of executing these commands, Redis will "queue" them. All the commands are executed once EXEC is called.

Calling DISCARD instead will flush the transaction queue and will exit the transaction.

The following is an example using the Ruby client:
@@ -57,7 +57,7 @@ replies, where every element is the reply of a single command in the
 transaction, in the same order the commands were queued.

When a Redis connection is in the context of a MULTI request, all the commands will reply with a simple string "QUEUED" if they are correct from the point of view of the syntax and arity (number of arguments) of the commaand. -Some command is still allowed to fail during execution time.

This is more clear if at protocol level: in the following example one command +Some commands are still allowed to fail during execution time.

This is more clear on the protocol level; In the following example one command will fail when executed even if the syntax is right:
 Trying 127.0.0.1...
@@ -75,7 +75,7 @@ EXEC
 +OK
 -ERR Operation against a key holding the wrong kind of value
 
-MULTI returned a two elements bulk reply in witch one of this is a +OK +MULTI returned a two elements bulk reply where one is an +OK code and one is a -ERR reply. It's up to the client lib to find a sensible way to provide the error to the user.

IMPORTANT: even when a command will raise an error, all the other commandsin the queue will be processed. Redis will NOT stop the processing ofcommands once an error is found.
Another example, again using the write protocol with telnet, shows how @@ -87,9 +87,8 @@ INCR a b c -ERR wrong number of arguments for 'incr' command
This time due to the syntax error the "bad" INCR command is not queued -at all.

The DISCARD command

DISCARD can be used in order to abort a transaction. No command will be -executed, and the state of the client is again the normal one, outside -
of a transaction. Example using the Ruby client:
+at all.

The DISCARD command

DISCARD can be used in order to abort a transaction. No command will be executed, and the state of the client is again the normal one, outside of a transaction. Example using the Ruby client: +
 ?> r.set("foo",1)
 => true
 >> r.multi