Class RedisDistributedLock

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

public class RedisDistributedLock extends Object implements DistributedLock
redis分布式锁实现
Author:
zuihou
  • Constructor Details

    • RedisDistributedLock

      public RedisDistributedLock(org.springframework.data.redis.core.RedisTemplate<String,Object> redisTemplate)
  • 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:
      释放结果