Class Lock

java.lang.Object
org.aoju.bus.limiter.support.lock.Lock
All Implemented Interfaces:
Limiter<Lock>
Direct Known Subclasses:
JdkLock, RedisLock, ZookeeperLock

public abstract class Lock extends Object implements Limiter<Lock>
Lock
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Lock

      public Lock()
  • Method Details

    • lock

      public abstract boolean lock(Object key)
    • unlock

      public abstract void unlock(Object key)
    • limit

      public boolean limit(Object key, Map<String,Object> args)
      Description copied from interface: Limiter
      对一个键值进行限制操作,并使用 args 参数 例如实现一个速率限制器,则 args 通常为速率参数
      Specified by:
      limit in interface Limiter<Lock>
      Parameters:
      key - 键
      args - 参数
      Returns:
      true/false
    • release

      public void release(Object key, Map<String,Object> args)
      Description copied from interface: Limiter
      对于一个键值释放限制,例如locker 对应于locker 的unlock 操作 某些种类的没有对应的释放操作 例如速率限制器 这是该方法应该是空实现
      Specified by:
      release in interface Limiter<Lock>
      Parameters:
      key - 键
      args - 参数