此内容没有您所选择的语言版本。
10.3.5. Implicit Pessimistic Locking Example
An example of implicit pessimistic locking using a transaction that runs on one of the cache nodes is as follows:
Procedure 10.4. Transaction with Implicit Pessimistic locking
- When the line
cache.put(K,V)
executes, a cluster-wide lock is acquired onK
.tx.begin() cache.put(K,V)
tx.begin() cache.put(K,V)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
cache.put(K2,V2)
executes, a cluster-wide lock is acquired onK2
.tx.begin() cache.put(K,V) cache.put(K2,V2)
tx.begin() cache.put(K,V) cache.put(K2,V2)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
cache.put(K,V5)
executes, the lock acquisition is non operational because a cluster-wide lock forK
has been previously acquired. Theput
operation will still occur.tx.begin() cache.put(K,V) cache.put(K2,V2) cache.put(K,V5)
tx.begin() cache.put(K,V) cache.put(K2,V2) cache.put(K,V5)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
tx.commit()
executes, all locks held for this transaction are released.Copy to Clipboard Copied! Toggle word wrap Toggle overflow