public interface Txn
txn.If(
new Cmp(KEY, Cmp.Op.GREATER, CmpTarget.value(VALUE)),
new Cmp(KEY, cmp.Op.EQUAL, CmpTarget.version(2))
).Then(
Op.put(KEY2, VALUE2, PutOption.DEFAULT),
Op.put(KEY3, VALUE3, PutOption.DEFAULT)
).Else(
Op.put(KEY4, VALUE4, PutOption.DEFAULT),
Op.put(KEY4, VALUE4, PutOption.DEFAULT)
).commit();
Txn also supports If, Then, and Else chaining. e.g.
txn.If(
new Cmp(KEY, Cmp.Op.GREATER, CmpTarget.value(VALUE))
).If(
new Cmp(KEY, cmp.Op.EQUAL, CmpTarget.version(VERSION))
).Then(
Op.put(KEY2, VALUE2, PutOption.DEFAULT)
).Then(
Op.put(KEY3, VALUE3, PutOption.DEFAULT)
).Else(
Op.put(KEY4, VALUE4, PutOption.DEFAULT)
).Else(
Op.put(KEY4, VALUE4, PutOption.DEFAULT)
).commit();
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<TxnResponse> |
commit()
tries to commit the transaction.
|
Txn |
Else(Op... ops)
takes a list of operations.
|
Txn |
If(Cmp... cmps)
takes a list of comparison.
|
Txn |
Then(Op... ops)
takes a list of operations.
|
Txn If(Cmp... cmps)
cmps - the comparisonsTxn Then(Op... ops)
ops - the operationsTxn Else(Op... ops)
ops - the operationsCompletableFuture<TxnResponse> commit()
Copyright © 2021. All rights reserved.