Authored by LUOXC

rename

... ... @@ -39,6 +39,8 @@ class DefaultRedisLock implements RedisLock {
private static final Long RELEASE_OK = 1L;
private final String lockValue;
private RedisTemplate<String, String> redisTemplate;
private String key;
... ... @@ -49,11 +51,6 @@ class DefaultRedisLock implements RedisLock {
private long expireTimeMillis;
/**
* lua script
*/
private String lockValue;
/**
* 锁标记
*/
private boolean locked;
... ... @@ -61,13 +58,13 @@ class DefaultRedisLock implements RedisLock {
final Random random = new Random();
DefaultRedisLock(Builder builder) {
this.lockValue = UUID.randomUUID().toString();
this.redisTemplate = builder.redisTemplate;
this.key = builder.key;
this.expireTimeMillis = builder.expireTimeMillis;
}
public boolean lock() {
updateLockValue();
while (true) {
if (acquire(lockValue, expireTimeMillis)) {
locked = true;
... ... @@ -78,7 +75,6 @@ class DefaultRedisLock implements RedisLock {
}
public boolean lock(long timeout, TimeUnit timeUnit) {
updateLockValue();
// 请求锁超时时间,纳秒
long timeoutNanos = timeUnit.toNanos(timeout);
// 系统当前时间,纳秒
... ... @@ -96,7 +92,6 @@ class DefaultRedisLock implements RedisLock {
}
public boolean tryLock() {
updateLockValue();
locked = acquireOr(lockValue, expireTimeMillis, false);
return locked;
}
... ... @@ -162,10 +157,6 @@ class DefaultRedisLock implements RedisLock {
}
}
private void updateLockValue() {
lockValue = UUID.randomUUID().toString();
}
/**
* 线程等待时间
*
... ...