Class Transactions
A class for running transactional operations against a Couchbase Cluster.
Inherited Members
Namespace: Couchbase.Transactions
Assembly: Couchbase.Transactions.dll
Syntax
public class Transactions : IDisposable, IAsyncDisposable
Fields
| Improve this Doc View SourceOpRetryDelay
A standard delay between retried operations.
Declaration
public static readonly TimeSpan OpRetryDelay
Field Value
Type | Description |
---|---|
TimeSpan |
Properties
| Improve this Doc View SourceConfig
Gets the TransactionConfig to apply to all transaction runs from this instance.
Declaration
public TransactionConfig Config { get; }
Property Value
Type | Description |
---|---|
TransactionConfig |
Methods
| Improve this Doc View SourceCreate(ICluster)
Create a Transactions instance for running transactions against the specified Couchbase.ICluster.
Declaration
public static Transactions Create(ICluster cluster)
Parameters
Type | Name | Description |
---|---|---|
Couchbase.ICluster | cluster | The cluster where your documents will be located. |
Returns
Type | Description |
---|---|
Transactions | A Transactions instance. |
Remarks
The instance returned from this method should be kept for the lifetime of your application and used like a singleton per Couchbase cluster you will be accessing.
Create(ICluster, TransactionConfig)
Create a Transactions instance for running transactions against the specified Couchbase.ICluster.
Declaration
public static Transactions Create(ICluster cluster, TransactionConfig config)
Parameters
Type | Name | Description |
---|---|---|
Couchbase.ICluster | cluster | The cluster where your documents will be located. |
TransactionConfig | config | The TransactionConfig to use for all transactions against this cluster. |
Returns
Type | Description |
---|---|
Transactions | A Transactions instance. |
Remarks
The instance returned from this method should be kept for the lifetime of your application and used like a singleton per Couchbase cluster you will be accessing.
Create(ICluster, TransactionConfigBuilder)
Create a Transactions instance for running transactions against the specified Couchbase.ICluster.
Declaration
public static Transactions Create(ICluster cluster, TransactionConfigBuilder configBuilder)
Parameters
Type | Name | Description |
---|---|---|
Couchbase.ICluster | cluster | The cluster where your documents will be located. |
TransactionConfigBuilder | configBuilder | The TransactionConfigBuilder to generate a TransactionConfig to use for all transactions against this cluster. |
Returns
Type | Description |
---|---|
Transactions | A Transactions instance. |
Remarks
The instance returned from this method should be kept for the lifetime of your application and used like a singleton per Couchbase cluster you will be accessing.
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing |
DisposeAsync()
Declaration
public async ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
QueryAsync<T>(String, SingleQueryTransactionConfigBuilder, IScope)
Run a single query as a transaction.
Declaration
public async Task<SingleQueryTransactionResult<T>> QueryAsync<T>(string statement, SingleQueryTransactionConfigBuilder config = null, IScope scope = null)
Parameters
Type | Name | Description |
---|---|---|
String | statement | The statement to execute. |
SingleQueryTransactionConfigBuilder | config | The configuration to use for this transaction. |
Couchbase.KeyValue.IScope | scope | The scope |
Returns
Type | Description |
---|---|
Task<SingleQueryTransactionResult<T>> | A SingleQueryTransactionResult<T> with the query results, if any. |
Type Parameters
Name | Description |
---|---|
T | The type of the result. Use Object for queries with no results. |
RunAsync(Func<AttemptContext, Task>)
Run a transaction agains the cluster.
Declaration
public Task<TransactionResult> RunAsync(Func<AttemptContext, Task> transactionLogic)
Parameters
Type | Name | Description |
---|---|---|
Func<AttemptContext, Task> | transactionLogic | A func representing the transaction logic. All data operations should use the methods on the AttemptContext provided. Do not mix and match non-transactional data operations. |
Returns
Type | Description |
---|---|
Task<TransactionResult> | The result of the transaction. |
RunAsync(Func<AttemptContext, Task>, PerTransactionConfig)
Run a transaction agains the cluster.
Declaration
public async Task<TransactionResult> RunAsync(Func<AttemptContext, Task> transactionLogic, PerTransactionConfig perConfig)
Parameters
Type | Name | Description |
---|---|---|
Func<AttemptContext, Task> | transactionLogic | A func representing the transaction logic. All data operations should use the methods on the AttemptContext provided. Do not mix and match non-transactional data operations. |
PerTransactionConfig | perConfig | A config with values unique to this specific transaction. |
Returns
Type | Description |
---|---|
Task<TransactionResult> | The result of the transaction. |