Public Member Functions | Properties | List of all members
GridGain.Transactions.ITransaction Interface Reference

Grid cache transaction. More...

Inherits IDisposable, and GridGain.Common.IAsyncSupport< ITransaction >.

Public Member Functions

bool SetRollbackonly ()
 Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction. More...
 
void Commit ()
 Commits this transaction. More...
 
void Rollback ()
 Rolls back this transaction. More...
 
void AddMeta< V > (string name, V val)
 Adds a new metadata. More...
 
V Meta< V > (string name)
 Gets metadata by name. More...
 
V RemoveMeta< V > (string name)
 Removes metadata by name. More...
 
- Public Member Functions inherited from GridGain.Common.IAsyncSupport< ITransaction >
TWithAsync WithAsync ()
 Gets component with asynchronous mode enabled. More...
 
IFuture GetFuture ()
 Gets and resets future for previous asynchronous operation. More...
 
IFuture< TResult > GetFuture< TResult > ()
 Gets and resets future for previous asynchronous operation. More...
 

Properties

Guid NodeId [get]
 ID of the node on which this transaction started. More...
 
long ThreadId [get]
 ID of the thread in which this transaction started. More...
 
DateTime StartTime [get]
 Start time of this transaction on this node. More...
 
TransactionIsolation Isolation [get]
 Transaction isolation level. More...
 
TransactionConcurrency Concurrency [get]
 Transaction concurrency mode. More...
 
TransactionState State [get]
 Current transaction state. More...
 
TimeSpan Timeout [get]
 Timeout value in milliseconds for this transaction. If transaction times out prior to it's completion, an exception will be thrown. More...
 
bool IsRollbackOnly [get]
 Gets a value indicating whether this transaction was marked as rollback-only. More...
 
- Properties inherited from GridGain.Common.IAsyncSupport< ITransaction >
bool IsAsync [get]
 Gets a value indicating whether this instance is in asynchronous mode. More...
 

Detailed Description

Cache transactions support the following isolation levels:

Cache transactions support the following concurrency models:

In addition to standard CacheAtomicityMode.TRANSACTIONAL behavior, GridGain also supports a lighter CacheAtomicityMode.ATOMIC mode as well. In this mode distributed transactions and distributed locking are not supported. Disabling transactions and locking allows to achieve much higher performance and throughput ratios. It is recommended that CacheAtomicityMode.TRANSACTIONAL mode is used whenever full ACID-compliant transactions are not needed.

You can use cache transactions as follows:

ICacheTx tx = cache.TxStart();
try
{
int v1 = cache<string, int>.Get("k1");
// Check if v1 satisfies some condition before doing a put.
if (v1 > 0)
cache.Put<string, int>("k1", 2);
cache.Removex("k2);
// Commit the transaction.
tx.Commit();
}
finally
{
tx.Dispose();
}

Member Function Documentation

void GridGain.Transactions.ITransaction.AddMeta< V > ( string  name,
V  val 
)
Parameters
nameMetadata name.
valMetadata value.
void GridGain.Transactions.ITransaction.Commit ( )
V GridGain.Transactions.ITransaction.Meta< V > ( string  name)
Parameters
nameMetadata name.
Returns
Metadata value.
Exceptions
KeyNotFoundExceptionIf metadata key was not found.
V GridGain.Transactions.ITransaction.RemoveMeta< V > ( string  name)
Parameters
nameMetadata name.
Returns
Value of removed metadata or default value for
V
type.
void GridGain.Transactions.ITransaction.Rollback ( )
bool GridGain.Transactions.ITransaction.SetRollbackonly ( )
Returns
True if rollback-only flag was set as a result of this operation, false if it was already set prior to this call or could not be set because transaction is already finishing up committing or rolling back.

Property Documentation

TransactionConcurrency GridGain.Transactions.ITransaction.Concurrency
get
TransactionIsolation GridGain.Transactions.ITransaction.Isolation
get
bool GridGain.Transactions.ITransaction.IsRollbackOnly
get
Guid GridGain.Transactions.ITransaction.NodeId
get

Originating node ID.

DateTime GridGain.Transactions.ITransaction.StartTime
get
TransactionState GridGain.Transactions.ITransaction.State
get
long GridGain.Transactions.ITransaction.ThreadId
get
TimeSpan GridGain.Transactions.ITransaction.Timeout
get