类 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
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidlock(String key, long expire, long acquireTimeout, Class<? extends LockExecutor> executor) 加锁方法protected LockExecutorobtainExecutor(Class<? extends LockExecutor> clazz) booleanreleaseLock(LockInfo lockInfo)
-
构造器详细资料
-
LockTemplate
public LockTemplate()
-
-
方法详细资料
-
lock
-
lock
-
lock
public LockInfo lock(String key, long expire, long acquireTimeout, Class<? extends LockExecutor> executor) 加锁方法- 参数:
key- 锁key 同一个key只能被一个客户端持有expire- 过期时间(ms) 防止死锁acquireTimeout- 尝试获取锁超时时间(ms)executor- 执行器- 返回:
- 加锁成功返回锁信息 失败返回null
-
releaseLock
-
obtainExecutor
-
afterPropertiesSet
- 指定者:
afterPropertiesSet在接口中org.springframework.beans.factory.InitializingBean- 抛出:
Exception
-