类 LockTemplate

  • 所有已实现的接口:
    org.springframework.beans.factory.InitializingBean

    public class LockTemplate
    extends Object
    implements org.springframework.beans.factory.InitializingBean

    锁模板方法

    作者:
    zengzhihong TaoYu
    • 构造器详细资料

      • LockTemplate

        public LockTemplate()
    • 方法详细资料

      • lock

        public LockInfo lock​(String key,
                             long expire,
                             long acquireTimeout)
      • 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)
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        指定者:
        afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBean
        抛出:
        Exception