类 AbstractSyncLock

java.lang.Object
cn.zhxu.toys.concurrent.AbstractSyncLock
所有已实现的接口:
SyncLock
直接已知子类:
RedisSyncLock, RedisTemplateSyncLock

public abstract class AbstractSyncLock extends Object implements SyncLock
Redis并发同步锁
从以下版本开始:
0.4.9
作者:
Troy.Zhou
  • 构造器详细资料

    • AbstractSyncLock

      public AbstractSyncLock()
  • 方法详细资料

    • lock

      public void lock(String name)
      从接口复制的说明: SyncLock
      获取锁
      指定者:
      lock 在接口中 SyncLock
      参数:
      name - 锁名称
    • lock

      public void lock(String name, int maxHoldSeconds)
      从接口复制的说明: SyncLock
      获取锁
      指定者:
      lock 在接口中 SyncLock
      参数:
      name - 锁名称
      maxHoldSeconds - 锁最大持有时间
    • lock

      public void lock(String name, int maxHoldSeconds, int maxWaitSeconds)
      从接口复制的说明: SyncLock
      获取锁
      指定者:
      lock 在接口中 SyncLock
      参数:
      name - 锁名称
      maxHoldSeconds - 持有锁最大时间
      maxWaitSeconds - 等待锁最大时间
    • lock

      public void lock(String name, String requestId)
      从接口复制的说明: SyncLock
      获取锁
      指定者:
      lock 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
    • lock

      public void lock(String name, String requestId, int maxHoldSeconds)
      从接口复制的说明: SyncLock
      获取锁
      指定者:
      lock 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      maxHoldSeconds - 锁最大持有时间
    • lock

      public void lock(String name, String requestId, int maxHoldSeconds, int maxWaitSeconds)
      从接口复制的说明: SyncLock
      获取锁
      指定者:
      lock 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      maxHoldSeconds - 持有锁最大时间
      maxWaitSeconds - 等待锁最大时间
    • doTryLock

      protected abstract boolean doTryLock(String key, String requestId, int maxHoldSeconds)
      上锁
      参数:
      key - Redis Key
      requestId - Redis Value
      maxHoldSeconds - Redis Expire Time
      返回:
      是否上锁成功
    • release

      public void release(String name)
      从接口复制的说明: SyncLock
      释放锁
      指定者:
      release 在接口中 SyncLock
      参数:
      name - 锁名称
    • release

      public void release(String name, String requestId)
      从接口复制的说明: SyncLock
      释放锁
      指定者:
      release 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
    • doUnLock

      protected abstract void doUnLock(String key, String requestId)
      解锁
      参数:
      key -
      requestId -
    • with

      public void with(String name, Runnable run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      with 在接口中 SyncLock
      参数:
      name - 锁名称
      run - 任务
    • with

      public void with(String name, int maxHoldSeconds, Runnable run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      with 在接口中 SyncLock
      参数:
      name - 锁名称
      maxHoldSeconds - 锁最大持有时间
      run - 任务
    • with

      public void with(String name, int maxHoldSeconds, int maxWaitSeconds, Runnable run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      with 在接口中 SyncLock
      参数:
      name - 锁名称
      maxHoldSeconds - 持有锁最大时间
      maxWaitSeconds - 等待锁最大时间
      run - 任务
    • with

      public void with(String name, String requestId, Runnable run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      with 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      run - 任务
    • with

      public void with(String name, String requestId, int maxHoldSeconds, Runnable run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      with 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      maxHoldSeconds - 锁最大持有时间
      run - 任务
    • with

      public void with(String name, String requestId, int maxHoldSeconds, int maxWaitSeconds, Runnable run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      with 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      maxHoldSeconds - 持有锁最大时间
      maxWaitSeconds - 等待锁最大时间
      run - 任务
    • run

      public <V> V run(String name, Callable<V> run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      run 在接口中 SyncLock
      参数:
      name - 锁名称
      run - 任务
      返回:
      the result of run
    • run

      public <V> V run(String name, int maxHoldSeconds, Callable<V> run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      run 在接口中 SyncLock
      参数:
      name - 锁名称
      maxHoldSeconds - 锁最大持有时间
      run - 任务
      返回:
      the result of run
    • run

      public <V> V run(String name, int maxHoldSeconds, int maxWaitSeconds, Callable<V> run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      run 在接口中 SyncLock
      参数:
      name - 锁名称
      maxHoldSeconds - 持有锁最大时间
      maxWaitSeconds - 等待锁最大时间
      run - 任务
      返回:
      the result of run
    • run

      public <V> V run(String name, String requestId, Callable<V> run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      run 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      run - 任务
      返回:
      the result of run
    • run

      public <V> V run(String name, String requestId, int maxHoldSeconds, Callable<V> run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      run 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      maxHoldSeconds - 锁最大持有时间
      run - 任务
      返回:
      the result of run
    • run

      public <V> V run(String name, String requestId, int maxHoldSeconds, int maxWaitSeconds, Callable<V> run)
      从接口复制的说明: SyncLock
      在锁内运行
      指定者:
      run 在接口中 SyncLock
      参数:
      name - 锁名称
      requestId - 请求者
      maxHoldSeconds - 持有锁最大时间
      maxWaitSeconds - 等待锁最大时间
      run - 任务
      返回:
      the result of run
    • getLockKey

      protected String getLockKey(String name)
    • getRequestId

      protected String getRequestId()
    • getKeyPrefix

      public String getKeyPrefix()
    • setKeyPrefix

      public void setKeyPrefix(String keyPrefix)
    • getNodeId

      public String getNodeId()
    • setNodeId

      public void setNodeId(String nodeId)
    • getMaxHoldSeconds

      public int getMaxHoldSeconds()
    • setMaxHoldSeconds

      public void setMaxHoldSeconds(int maxHoldSeconds)
    • getMaxWaitSeconds

      public int getMaxWaitSeconds()
    • setMaxWaitSeconds

      public void setMaxWaitSeconds(int maxWaitSeconds)
    • getRetryInterval

      public int getRetryInterval()
    • setRetryInterval

      public void setRetryInterval(int retryInterval)