public class TestAndSetOp extends Object implements TransactionOperation, TransactionSingleOpOperation
newValue is only written if the
currently stored value is oldValue.| Constructor and Description |
|---|
TestAndSetOp(OtpErlangString key,
OtpErlangObject oldValue,
OtpErlangObject newValue)
Constructor
|
TestAndSetOp(String key,
OldT oldValue,
NewT newValue)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
OtpErlangObject |
getErlang(boolean compressed)
Gets the erlang representation of the operation.
|
OtpErlangString |
getKey()
Gets the key the operation is working on (if available)
|
OtpErlangObject |
getResult()
Gets the (raw Erlang) result set via
Operation.setResult(OtpErlangObject, boolean). |
boolean |
getResultCompressed()
Determines if the result set via
Operation.setResult(OtpErlangObject, boolean) is compressed or not. |
Object |
processResult()
Processes the result set by
Operation.setResult(OtpErlangObject, boolean). |
Object |
processResultSingle()
Processes the result set by
Operation.setResult(OtpErlangObject, boolean)
assuming that operation was committed. |
void |
setResult(OtpErlangObject resultRaw,
boolean compressed)
Sets the raw erlang result value.
|
String |
toString() |
public TestAndSetOp(OtpErlangString key, OtpErlangObject oldValue, OtpErlangObject newValue)
key - the key to write the value tooldValue - the old value to verifynewValue - the new value to write of oldValue is correctpublic TestAndSetOp(String key, OldT oldValue, NewT newValue)
key - the key to write the value tooldValue - the old value to verifynewValue - the new value to write of oldValue is correctpublic OtpErlangObject getErlang(boolean compressed)
Operationpublic OtpErlangString getKey()
Operationpublic void setResult(OtpErlangObject resultRaw, boolean compressed)
OperationOperation.processResult().public OtpErlangObject getResult()
OperationOperation.setResult(OtpErlangObject, boolean).public boolean getResultCompressed()
OperationOperation.setResult(OtpErlangObject, boolean) is compressed or not.getResultCompressed in interface Operationpublic Object processResult() throws NotFoundException, KeyChangedException, UnknownException
OperationOperation.setResult(OtpErlangObject, boolean).
Note: the created value is not cached!processResult in interface OperationNotFoundException - if the requested key does not existKeyChangedException - if the key did not match old_valueUnknownException - if any other error occurspublic Object processResultSingle() throws AbortException, NotFoundException, KeyChangedException, UnknownException
TransactionSingleOpOperationOperation.setResult(OtpErlangObject, boolean)
assuming that operation was committed.
In contrast to Operation.processResult() operations like WriteOp
will throw a proper AbortException for their commit part instead
of an UnknownException.
Note: the created value is not cached!processResultSingle in interface TransactionSingleOpOperationAbortException - if a commit failedNotFoundException - if the requested key does not existKeyChangedException - if the key did not match old_valueUnknownException - if any other error occurs