Class CaffeineDistributedLock

java.lang.Object
top.tangyh.basic.cache.lock.CaffeineDistributedLock
All Implemented Interfaces:
DistributedLock

public class CaffeineDistributedLock extends Object implements DistributedLock
分布式锁 只能用redis实现 写这个类的目的,只是为了防止代码启动报错
Author:
zuihou
  • Constructor Details

    • CaffeineDistributedLock

      public CaffeineDistributedLock()
  • Method Details

    • lock

      public boolean lock(String key, long expire, int retryTimes, long sleepMillis)
      Description copied from interface: DistributedLock
      获取锁
      Specified by:
      lock in interface DistributedLock
      Parameters:
      key - key
      expire - 获取锁超时时间
      retryTimes - 重试次数
      sleepMillis - 获取锁失败的重试间隔
      Returns:
      成功/失败
    • releaseLock

      public boolean releaseLock(String key)
      Description copied from interface: DistributedLock
      释放锁
      Specified by:
      releaseLock in interface DistributedLock
      Parameters:
      key - key值
      Returns:
      释放结果