tx.begin() cache.lock(K) // acquire cluster wide lock on K cache.put(K,V5) // guaranteed to succeed tx.commit() // releases locks
Infinispan cache interface exposes lock API that allows cache users to explicitly lock set of cache keys eagerly during a transaction. Lock call attempts to lock specified cache keys across all cluster nodes and it either succeeds or fails. All locks are released during commit or rollback phase.
Consider a transaction running on one of the cache nodes:
tx.begin() cache.lock(K) // acquire cluster wide lock on K cache.put(K,V5) // guaranteed to succeed tx.commit() // releases locks