| Modifier and Type | Field and Description |
|---|---|
static String |
STORAGE_PREFIX |
| Constructor and Description |
|---|
RedisBasedLock(io.vertx.redis.RedisClient redisClient) |
| Modifier and Type | Method and 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.
|
public static final String STORAGE_PREFIX
public io.vertx.core.Future<Boolean> acquireLock(String lock, String token, long lockExpiryMs)
Locktoken parameter value must be unique across all clients and all lock requests. The lockExpiryMs
parameter defines the expiry of the lock.
When not manually released, the lock will be released automatically when expired.acquireLock in interface Locklock - The name of the lock to acquiretoken - A unique token to define the owner of the locklockExpiryMs - The lock expiry in millisecondspublic io.vertx.core.Future<Boolean> releaseLock(String lock, String token)
Locktoken parameter value is used to verify that only the owner of the lock can release it.
The token parameter value also prevents the original owner of an already expired lock to release a lock
which has been acquired by another client.releaseLock in interface Locklock - The name of the lock to releasetoken - A unique token to verify if the owner of the lock tries to release the lockCopyright © 2016–2018. All rights reserved.