|
@@ -15,8 +15,8 @@ public class RedisLock {
|
|
|
|
|
|
public boolean tryLock(String lockKey, String lockValue, long expireTime, TimeUnit timeUnit) {
|
|
|
ValueOperations<String, Object> valueOps = redisTemplate.opsForValue();
|
|
|
- Boolean result = valueOps.setIfAbsent(lockKey, lockValue, expireTime, timeUnit);
|
|
|
// setIfAbsent 方法会在键不存在时设置键值对,并返回是否成功
|
|
|
+ Boolean result = valueOps.setIfAbsent(lockKey, lockValue, expireTime, timeUnit);
|
|
|
return result != null && result;
|
|
|
}
|
|
|
|