This is what most normal applications want, especially if they rely on receiving command results serially. Under normal conditions, Lettuce executes commands as soon as they are called by an API client. Exec returns a TransactionResult which contains a list of responses. In asynchronous mode, the commands return RedisFuture. In synchronous mode, the commands return null. When a transaction is started, the subsequent commands are not executed until exec() is called. The call to multi starts the transaction. String thirdResult = transactionResult.get(0) String secondResult = transactionResult.get(0) String firstResult = transactionResult.get(0) TransactionResult transactionResult = execResult.get() RedisFuture execResult = asyncCommands.exec() RedisFuture result3 = t("ke圓", "value3") RedisFuture result2 = t("key2", "value2") RedisFuture result1 = t("key1", "value1") Let's look at an example: asyncCommands.multi() Once exec() is called, all commands are executed in the order specified. Redis will not perform a rollback if one of them fails. Commands from another user won't be executed until the transaction finishes.Įither all commands are executed, or none of them are. These commands are guaranteed to be executed in order and exclusively. Transactions allow the execution of a set of commands in a single atomic step.
0 Comments
Leave a Reply. |