|
Couchbase C++ SDK 1.4.0 (rev. 59aa900)
|
The transactions object is used to initiate a transaction. More...
#include <couchbase/transactions.hxx>
Public Member Functions | |
| auto | run (txn_logic &&logic, const transaction_options &cfg={}) -> std::pair< error, transaction_result > |
| Run a blocking transaction. | |
| void | run (async_txn_logic &&logic, async_txn_complete_logic &&complete_callback, const transaction_options &cfg={}) |
| Run an asynchronous transaction. | |
| transactions (std::shared_ptr< core::transactions::transactions > core_txns) | |
The transactions object is used to initiate a transaction.
|
explicit |
| void run | ( | async_txn_logic && | logic, |
| async_txn_complete_logic && | complete_callback, | ||
| const transaction_options & | cfg = {} ) |
Run an asynchronous transaction.
You can supply a lambda or function which uses a yielded async_attempt_context to perform a transaction, where each transaction operation is asynchronous. A simple usage would be to get 3 document and replace the contents of each. In the example below, we get the 3 documents in parallel, and update each when the get returns the document. This can be significantly faster than getting each document in serial, and updating it using the blocking api:
| logic | a lambda or function which uses the yielded async_attempt_context to perform the desired transactional operations. |
| complete_callback | a lambda or function to which is yielded a {transaction_error_context} and {transaction_result}. |
| cfg | if passed in, these options override the defaults, or those set in the cluster_options. |
| auto run | ( | txn_logic && | logic, |
| const transaction_options & | cfg = {} ) -> std::pair< error, transaction_result > |
Run a blocking transaction.
You can supply a lambda or function which uses a yielded attempt_context to perform a transaction, where each transaction operation is blocking. A simple usage would be to get a document and replace the contents:
| logic | a lambda or function which uses the yielded attempt_context to perform the desired transactional operations. |
| cfg | if passed in, these options override the defaults, or those set in the cluster_options. |
error, and a transaction_result representing the results of the transaction.