类 LockUtil
java.lang.Object
com.sh.wf.module.util.LockUtil
Description: redis分布式锁工具类
Title:首亨软件 - 聚天平台
- 从以下版本开始:
- 2021年1月25日
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleanreleaseDistributedLock(DataCenter dc, String lockKey, String requestId) static booleanreleaseDistributedLock(CacheRedis cacheRedis, String lockKey, String requestId) 释放分布式锁static booleantryGetDistributedLock(DataCenter dc, String lockKey, String requestId, long millisecondsToExpire) static booleantryGetDistributedLock(CacheRedis cacheRedis, String lockKey, String requestId, long millisecondsToExpire) 尝试获取分布式锁
-
构造器详细资料
-
LockUtil
public LockUtil()
-
-
方法详细资料
-
tryGetDistributedLock
public static boolean tryGetDistributedLock(DataCenter dc, String lockKey, String requestId, long millisecondsToExpire) -
tryGetDistributedLock
public static boolean tryGetDistributedLock(CacheRedis cacheRedis, String lockKey, String requestId, long millisecondsToExpire) 尝试获取分布式锁- 参数:
cacheRedis- Redis客户端lockKey- 锁requestId- 请求标识,一般用uuid或能表示当前请求的即可millisecondsToExpire- 超期时间,单位:ms- 返回:
- 是否获取成功
-
releaseDistributedLock
-
releaseDistributedLock
public static boolean releaseDistributedLock(CacheRedis cacheRedis, String lockKey, String requestId) 释放分布式锁- 参数:
cacheRedis- Redis客户端lockKey- 锁requestId- 请求标识- 返回:
- 是否释放成功
-