Class RedisBasedLock
- java.lang.Object
-
- org.swisspush.gateleen.core.lock.impl.RedisBasedLock
-
-
Field Summary
Fields Modifier and Type Field Description static StringSTORAGE_PREFIX
-
Constructor Summary
Constructors Constructor Description RedisBasedLock(io.vertx.redis.client.RedisAPI redisAPI)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.vertx.core.Future<Boolean>acquireLock(String lock, String token, long lockExpiryMs)Try to acquire a lock.io.vertx.core.Future<Boolean>releaseLock(String lock, String token)Try to release a lock.
-
-
-
Field Detail
-
STORAGE_PREFIX
public static final String STORAGE_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
acquireLock
public io.vertx.core.Future<Boolean> acquireLock(String lock, String token, long lockExpiryMs)
Description copied from interface:LockTry to acquire a lock. Thetokenparameter value must be unique across all clients and all lock requests. ThelockExpiryMsparameter defines the expiry of the lock. When not manually released, the lock will be released automatically when expired.- Specified by:
acquireLockin interfaceLock- Parameters:
lock- The name of the lock to acquiretoken- A unique token to define the owner of the locklockExpiryMs- The lock expiry in milliseconds- Returns:
- Returns a Future holding a Boolean value whether the lock could be successfully acquired or not
-
releaseLock
public io.vertx.core.Future<Boolean> releaseLock(String lock, String token)
Description copied from interface:LockTry to release a lock. Thetokenparameter value is used to verify that only the owner of the lock can release it. Thetokenparameter value also prevents the original owner of an already expired lock to release a lock which has been acquired by another client.- Specified by:
releaseLockin interfaceLock- Parameters:
lock- The name of the lock to releasetoken- A unique token to verify if the owner of the lock tries to release the lock- Returns:
- Returns a Promise holding a Boolean value whether the lock could be sucsessfully released or not
-
-