public class RedisDLock extends BaseRedisDLock
| Modifier and Type | Field and Description |
|---|---|
static String |
LOCK_PROP_REDIS_HOST_AND_PORT
To override the
setRedisHostAndPort(String) setting. |
LOCK_PROP_REDIS_PASSWORD, myOwnRedisDEFAULT_LOCK_DURATION_MS| Constructor and Description |
|---|
RedisDLock(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected redis.clients.jedis.Jedis |
getJedis() |
String |
getRedisHostAndPort()
Redis' host and port scheme (format
host:port). |
RedisDLock |
init() |
LockResult |
lock(String clientId,
long lockDurationMs)
Acquire the lock for
clientId for a duration of
lockDurationMs. |
RedisDLock |
setRedisHostAndPort(String redisHostAndPort)
Sets Redis' host and port scheme (format
host:port). |
LockResult |
unlock(String clientId)
Release the lock.
|
destroy, getJedisConnector, getRedisPassword, getScriptLock, getScriptUnlock, setJedisConnector, setRedisPassword, setScriptLock, setScriptUnlock, updateLockHolderclose, getClientId, getLockProperties, getLockProperty, getName, getTimestampExpiry, lock, setClientId, setLockProperties, setName, setTimestampExpiry, toString, updateLockHolderpublic static final String LOCK_PROP_REDIS_HOST_AND_PORT
setRedisHostAndPort(String) setting.public RedisDLock(String name)
protected redis.clients.jedis.Jedis getJedis()
public String getRedisHostAndPort()
host:port).public RedisDLock setRedisHostAndPort(String redisHostAndPort)
host:port).redisHostAndPort - public RedisDLock init()
init in class BaseRedisDLockpublic LockResult lock(String clientId, long lockDurationMs)
clientId for a duration of
lockDurationMs.
Reentrant: lock can be acquired multiple times by the same
clientId. Lock's expiry will be extended accordingly.
clientId - within a namespace, only one client is allowed to hold lock as
a given timeLockResult.SUCCESSFUL if successful,
LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently
hold by another clientpublic LockResult unlock(String clientId)
clientId - within a namespace, only one client is allowed to hold lock as
a given timeLockResult.SUCCESSFUL if successful,
LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently
hold by another client, LockResult.NOT_FOUND if the lock
is not currently hold by any client (not locked before, or
already expired)Copyright © 2018 DDTH. All rights reserved.