类 LockTemplate
- java.lang.Object
-
- com.baomidou.lock.LockTemplate
-
- 所有已实现的接口:
org.springframework.beans.factory.InitializingBean
public class LockTemplate extends Object implements org.springframework.beans.factory.InitializingBean
锁模板方法
- 作者:
- zengzhihong TaoYu
-
-
构造器概要
构造器 构造器 说明 LockTemplate()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()LockInfolock(String key)LockInfolock(String key, long expire, long acquireTimeout)LockInfolock(String key, long expire, long acquireTimeout, Class<? extends LockExecutor> executor)加锁方法protected LockExecutorobtainExecutor(Class<? extends LockExecutor> clazz)booleanreleaseLock(LockInfo lockInfo)
-
-
-
方法详细资料
-
lock
public LockInfo lock(String key, long expire, long acquireTimeout, Class<? extends LockExecutor> executor)
加锁方法- 参数:
key- 锁key 同一个key只能被一个客户端持有expire- 过期时间(ms) 防止死锁acquireTimeout- 尝试获取锁超时时间(ms)executor- 执行器- 返回:
- 加锁成功返回锁信息 失败返回null
-
releaseLock
public boolean releaseLock(LockInfo lockInfo)
-
obtainExecutor
protected LockExecutor obtainExecutor(Class<? extends LockExecutor> clazz)
-
-