1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
   |  public class RedissonLock extends RedissonExpirable implements RLock { 	 }
 
  <T> RFuture<T> tryLockInnerAsync(long leaseTime, TimeUnit unit, long threadId, RedisStrictCommand<T> command) {     internalLockLeaseTime = unit.toMillis(leaseTime);                                                  return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, command,               "if (redis.call('exists', KEYS[1]) == 0) then " +                   "redis.call('hset', KEYS[1], ARGV[2], 1); " +                   "redis.call('pexpire', KEYS[1], ARGV[1]); " +                   "return nil; " +               "end; " +               "if (redis.call('hexists', KEYS[1], ARGV[2]) == 1) then " +                   "redis.call('hincrby', KEYS[1], ARGV[2], 1); " +                   "redis.call('pexpire', KEYS[1], ARGV[1]); " +                   "return nil; " +               "end; " +               "return redis.call('pttl', KEYS[1]);",                 Collections.<Object>singletonList(getName()), internalLockLeaseTime, getLockName(threadId)); }
  protected RFuture<Boolean> unlockInnerAsync(long threadId) {     return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN,     	                 "if (redis.call('exists', KEYS[1]) == 0) then " +                 "redis.call('publish', KEYS[2], ARGV[1]); " +                 "return 1; " +             "end;" +                          "if (redis.call('hexists', KEYS[1], ARGV[3]) == 0) then " +                 "return nil;" +             "end; " +                          "local counter = redis.call('hincrby', KEYS[1], ARGV[3], -1); " +                          "if (counter > 0) then " +                 "redis.call('pexpire', KEYS[1], ARGV[2]); " +                 "return 0; " +                          "else " +                 "redis.call('del', KEYS[1]); " +                 "redis.call('publish', KEYS[2], ARGV[1]); " +                 "return 1; "+             "end; " +             "return nil;",             Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(threadId)); }
 
  |