Interface RFencedLockAsync

All Superinterfaces:
RLockAsync
All Known Subinterfaces:
RFencedLock
All Known Implementing Classes:
RedissonFencedLock

public interface RFencedLockAsync extends RLockAsync
Async interface for Redis based implementation of Fenced Lock with reentrancy support.

Each lock acquisition increases fencing token. It should be checked if it's greater or equal with the previous one by the service guarded by this lock and reject operation if condition is false.

Author:
Nikita Koksharov
  • Method Details

    • getTokenAsync

      RFuture<Long> getTokenAsync()
      Returns current fencing token
      Returns:
      fencing token
    • lockAndGetTokenAsync

      RFuture<Long> lockAndGetTokenAsync()
      Acquires the lock and returns increased fencing token. Waits if necessary until lock became available.
      Returns:
      fencing token
    • lockAndGetTokenAsync

      RFuture<Long> lockAndGetTokenAsync(long leaseTime, TimeUnit unit)
      Acquires the lock with defined leaseTime and returns increased fencing token. Waits if necessary until lock became available.

      Lock will be released automatically after defined leaseTime interval.

      Parameters:
      leaseTime - the maximum time to hold the lock after it's acquisition, if it hasn't already been released by invoking unlock. If leaseTime is -1, hold the lock until explicitly unlocked.
      unit - the time unit
      Returns:
      fencing token
    • tryLockAndGetTokenAsync

      RFuture<Long> tryLockAndGetTokenAsync()
      Tries to acquire the lock and returns increased fencing token if operation successful.
      Returns:
      fencing token if lock acquired otherwise null
    • tryLockAndGetTokenAsync

      RFuture<Long> tryLockAndGetTokenAsync(long waitTime, TimeUnit unit)
      Tries to acquire the lock and returns increased fencing token. Waits up to defined waitTime if necessary until the lock became available.
      Parameters:
      waitTime - the maximum time to acquire the lock
      unit - time unit
      Returns:
      fencing token if lock is successfully acquired, otherwise null if lock is already set.
    • tryLockAndGetTokenAsync

      RFuture<Long> tryLockAndGetTokenAsync(long waitTime, long leaseTime, TimeUnit unit)
      Tries to acquire the lock with defined leaseTime and returns increased fencing token. Waits up to defined waitTime if necessary until the lock became available.

      Lock will be released automatically after defined leaseTime interval.

      Parameters:
      waitTime - the maximum time to acquire the lock
      leaseTime - lease time
      unit - time unit
      Returns:
      fencing token if lock is successfully acquired, otherwise null if lock is already set.