@ConditionalOnClass(value=org.redisson.api.RedissonClient.class)
@ConditionalOnProperty(prefix="ms.lock",
name="lockerType",
havingValue="REDIS",
matchIfMissing=true)
public class RedissonDistributedLock
extends Object
implements DistributedLock
| 构造器和说明 |
|---|
RedissonDistributedLock() |
| 限定符和类型 | 方法和说明 |
|---|---|
<T> T |
lock(String lockName,
LockType lockType,
long waitTime,
long leaseTime,
TimeUnit timeUnit,
CheckedSupplier<T> supplier)
自动获取锁后执行方法
|
boolean |
tryLock(String lockName,
LockType lockType,
long waitTime,
long leaseTime,
TimeUnit timeUnit)
尝试获取锁
|
void |
unLock(String lockName,
LockType lockType)
解锁
|
lockFair, lockReentrant, tryFairLockpublic boolean tryLock(String lockName, LockType lockType, long waitTime, long leaseTime, TimeUnit timeUnit) throws InterruptedException
tryLock 在接口中 DistributedLocklockName - 锁名lockType - 锁类型waitTime - 等待时间leaseTime - 自动解锁时间,一定要大于方法执行时间timeUnit - 时间单位InterruptedException - InterruptedExceptionpublic void unLock(String lockName, LockType lockType)
unLock 在接口中 DistributedLocklockName - 锁名lockType - 锁类型public <T> T lock(String lockName, LockType lockType, long waitTime, long leaseTime, TimeUnit timeUnit, CheckedSupplier<T> supplier)
lock 在接口中 DistributedLocklockName - 锁名lockType - 锁类型waitTime - 等待锁超时时间leaseTime - 自动解锁时间,默认100timeUnit - 时间单位supplier - 获取锁后的回调Copyright © 2023. All rights reserved.