Authored by LUOXC

rename

@@ -39,6 +39,8 @@ class DefaultRedisLock implements RedisLock { @@ -39,6 +39,8 @@ class DefaultRedisLock implements RedisLock {
39 39
40 private static final Long RELEASE_OK = 1L; 40 private static final Long RELEASE_OK = 1L;
41 41
  42 + private final String lockValue;
  43 +
42 private RedisTemplate<String, String> redisTemplate; 44 private RedisTemplate<String, String> redisTemplate;
43 45
44 private String key; 46 private String key;
@@ -49,11 +51,6 @@ class DefaultRedisLock implements RedisLock { @@ -49,11 +51,6 @@ class DefaultRedisLock implements RedisLock {
49 private long expireTimeMillis; 51 private long expireTimeMillis;
50 52
51 /** 53 /**
52 - * lua script  
53 - */  
54 - private String lockValue;  
55 -  
56 - /**  
57 * 锁标记 54 * 锁标记
58 */ 55 */
59 private boolean locked; 56 private boolean locked;
@@ -61,13 +58,13 @@ class DefaultRedisLock implements RedisLock { @@ -61,13 +58,13 @@ class DefaultRedisLock implements RedisLock {
61 final Random random = new Random(); 58 final Random random = new Random();
62 59
63 DefaultRedisLock(Builder builder) { 60 DefaultRedisLock(Builder builder) {
  61 + this.lockValue = UUID.randomUUID().toString();
64 this.redisTemplate = builder.redisTemplate; 62 this.redisTemplate = builder.redisTemplate;
65 this.key = builder.key; 63 this.key = builder.key;
66 this.expireTimeMillis = builder.expireTimeMillis; 64 this.expireTimeMillis = builder.expireTimeMillis;
67 } 65 }
68 66
69 public boolean lock() { 67 public boolean lock() {
70 - updateLockValue();  
71 while (true) { 68 while (true) {
72 if (acquire(lockValue, expireTimeMillis)) { 69 if (acquire(lockValue, expireTimeMillis)) {
73 locked = true; 70 locked = true;
@@ -78,7 +75,6 @@ class DefaultRedisLock implements RedisLock { @@ -78,7 +75,6 @@ class DefaultRedisLock implements RedisLock {
78 } 75 }
79 76
80 public boolean lock(long timeout, TimeUnit timeUnit) { 77 public boolean lock(long timeout, TimeUnit timeUnit) {
81 - updateLockValue();  
82 // 请求锁超时时间,纳秒 78 // 请求锁超时时间,纳秒
83 long timeoutNanos = timeUnit.toNanos(timeout); 79 long timeoutNanos = timeUnit.toNanos(timeout);
84 // 系统当前时间,纳秒 80 // 系统当前时间,纳秒
@@ -96,7 +92,6 @@ class DefaultRedisLock implements RedisLock { @@ -96,7 +92,6 @@ class DefaultRedisLock implements RedisLock {
96 } 92 }
97 93
98 public boolean tryLock() { 94 public boolean tryLock() {
99 - updateLockValue();  
100 locked = acquireOr(lockValue, expireTimeMillis, false); 95 locked = acquireOr(lockValue, expireTimeMillis, false);
101 return locked; 96 return locked;
102 } 97 }
@@ -162,10 +157,6 @@ class DefaultRedisLock implements RedisLock { @@ -162,10 +157,6 @@ class DefaultRedisLock implements RedisLock {
162 } 157 }
163 } 158 }
164 159
165 - private void updateLockValue() {  
166 - lockValue = UUID.randomUUID().toString();  
167 - }  
168 -  
169 /** 160 /**
170 * 线程等待时间 161 * 线程等待时间
171 * 162 *