IGridMapPessimisticTx TKey, TValue  InterfaceIBM WebSphere™ eXtreme Scale Client for .NET API Specification
IBM WebSphere™ eXtreme Scale Client for .NET Release 8.6.0.0 API Specification

This is a handle to a map using the pessimistic locking strategy and manual transaction demarcation. All data access operations must occur within an active transaction.

Use the Transaction property to access the IGridTransaction instance that is associated with this map instance, and use the Begin  method to begin a transaction. All keys in a single transaction must resolve to the same partition.

An instance of this IGridMapPessimisticTx is not thread-safe, and can only be used by the thread at a time. Use the Dispose  method when finished with the map, to improve performance.

Namespace: IBM.WebSphere.Caching.Map
Assembly: Client.Api (in Client.Api.dll) Version: 8.6.0.0
Syntax

Type Parameters

TKey
Generic type key.
TValue
Generic type value.
Remarks

Each data access method includes a "Specification details" table that includes the following information:

Required permission:The permission required to use the API.
Pessimistic read lock acquired:The type of lock that is acquired when you are using pessimistic locking with repeatable read transaction isolation.
Pessimistic read lock held:The type of lock that is held for the duration of the transaction with repeatable read transaction isolation. Locks can be upgraded but not demoted during a transaction.
Cache tier:Identifies the map cache tiers that are included when fetching or updating cache entries in the call and under what circumstances. The following tiers are available for IGridMapPessimisticTx maps:
  • Transactional Cache
  • Server Cache (data grid)
  • Loader (if enabled)

Examples

This sample demonstrates how to put a new cache entry into the data grid:
// Assume we have already connected to the Grid...
IGrid grid = ...

// Retrieve a new map instance.
IGridMapPessimisticTx<long, string> map = grid.GetGridMapPessimisticTx<long, string>("MyPessimisticMap");

// Start a transaction.
map.Transaction.Begin();

try
{
    // Lock the entry in the data grid with an Upgradable lock.
    map.Lock(123, LockMode.Upgradable);

    // Put the entry in the transactional cache.
    map.Put(123, "Value to cache");

    // Commit the transaction to the data grid.
    map.Transaction.Commit();
}
catch(GridException)
{
    // Clean-up the transaction if the lock could not be 
    // acquired, or the commit failed. 
    if(map.Transaction.Active)
    {
        try
        {
            map.Transaction.Rollback();
        }
        catch(Exception)
        {
            // Optionally log this exception, or ignore the exception.
        }
    }

    // Dispose the map (optional, but it improves performance)
    map.Dispose();

    // Rethrow the real exception. 
    throw;
 }
See Also