public class ClusteredRedisDLock extends BaseRedisDLock
ICache.| Modifier and Type | Field and Description |
|---|---|
static String |
LOCK_PROP_REDIS_HOSTS_AND_PORTS
To override the
setRedisHostsAndPorts(String) setting. |
LOCK_PROP_REDIS_PASSWORD, myOwnRedisDEFAULT_LOCK_DURATION_MS| Constructor and Description |
|---|
ClusteredRedisDLock(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected redis.clients.jedis.JedisCluster |
getJedis() |
String |
getRedisHostsAndPorts()
Redis' hosts and ports scheme (format
host1:port1,host2:port2,host3:port3). |
ClusteredRedisDLock |
init() |
LockResult |
lock(String clientId,
long lockDurationMs)
Acquire the lock for
clientId for a duration of
lockDurationMs. |
ClusteredRedisDLock |
setRedisHostsAndPorts(String redisHostsAndPorts)
Sets Redis' hosts and ports scheme (format
host1:port1,host2:port2,host3:port3). |
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_HOSTS_AND_PORTS
setRedisHostsAndPorts(String) setting.public ClusteredRedisDLock(String name)
public String getRedisHostsAndPorts()
host1:port1,host2:port2,host3:port3).public ClusteredRedisDLock setRedisHostsAndPorts(String redisHostsAndPorts)
host1:port1,host2:port2,host3:port3).redisHostsAndPorts - public ClusteredRedisDLock init()
init in class BaseRedisDLockprotected redis.clients.jedis.JedisCluster getJedis()
public 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.