public class JdbcLockRegistry extends Object implements ExpirableLockRegistry
ExpirableLockRegistry using a shared database to co-ordinate the locks.
Provides the same semantics as the
DefaultLockRegistry, but the
locks taken will be global, as long as the underlying database supports the
"serializable" isolation level in its transactions.| Constructor and Description |
|---|
JdbcLockRegistry(LockRepository client) |
| Modifier and Type | Method and Description |
|---|---|
void |
expireUnusedOlderThan(long age)
Remove locks last acquired more than 'age' ago that are not currently locked.
|
Lock |
obtain(Object lockKey)
Obtains the lock associated with the parameter object.
|
void |
setIdleBetweenTries(java.time.Duration idleBetweenTries)
Specify a @link Duration} to sleep between lock record insert/update attempts.
|
public JdbcLockRegistry(LockRepository client)
public void setIdleBetweenTries(java.time.Duration idleBetweenTries)
idleBetweenTries - the Duration to sleep between insert/update attempts.public Lock obtain(Object lockKey)
LockRegistryobtain in interface LockRegistrylockKey - The object with which the lock is associated.public void expireUnusedOlderThan(long age)
ExpirableLockRegistryexpireUnusedOlderThan in interface ExpirableLockRegistryage - the time since the lock was last obtained.