9.4. Explicit Pessimistic Locking Example
The following is an example of explicit pessimistic locking that depicts a transaction that runs on one of the cache nodes:
tx.begin() cache.lock(K) cache.put(K,V5) tx.commit()
When the line
cache.lock(K)
executes, a cluster-wide lock is acquired on K
.
When the line
cache.put(K,V5)
executes, it guarantees success.
When the line
tx.commit()
executes, the locks held for this process are released.