public class JdbcLockRegistry extends Object implements ExpirableLockRegistry, RenewableLockRegistry
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 |
renewLock(Object lockKey)
Renew the time to live of the lock is 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)
LockRegistry
obtain
in interface LockRegistry
lockKey
- The object with which the lock is associated.public void expireUnusedOlderThan(long age)
ExpirableLockRegistry
expireUnusedOlderThan
in interface ExpirableLockRegistry
age
- the time since the lock was last obtained.public void renewLock(Object lockKey)
RenewableLockRegistry
renewLock
in interface RenewableLockRegistry
lockKey
- The object with which the lock is associated.