@Service public class RedisLockServiceImpl extends Object implements DistributedLock
构造器和说明 |
---|
RedisLockServiceImpl() |
public void lock(String lockKey) throws InterruptedException
DistributedLock
lock
在接口中 DistributedLock
lockKey
- 锁键InterruptedException
public void lock(String lockKey, long leaseTime, TimeUnit unit) throws InterruptedException
DistributedLock
lock
在接口中 DistributedLock
lockKey
- 锁键leaseTime
- 持有时长unit
- 时间单位InterruptedException
public boolean tryLock(String lockKey, long waitTime, long leaseTime, TimeUnit timeUnit) throws InterruptedException
DistributedLock
tryLock
在接口中 DistributedLock
lockKey
- 锁键waitTime
- 等待时长leaseTime
- 持有时长timeUnit
- 时间单位InterruptedException
public void unlock(String lockKey)
DistributedLock
unlock
在接口中 DistributedLock
lockKey
- 锁键