Class RedisDLock

    • Constructor Detail

      • RedisDLock

        public RedisDLock​(String name)
    • Method Detail

      • getRedisHostAndPort

        public String getRedisHostAndPort()
        Redis' host and port scheme (format host:port).
        Returns:
      • setRedisHostAndPort

        public RedisDLock setRedisHostAndPort​(String redisHostAndPort)
        Redis' host and port scheme (format host:port).
        Parameters:
        redisHostAndPort -
        Returns:
      • buildJedisConnector

        protected com.github.ddth.commons.redis.JedisConnector buildJedisConnector()
        Specified by:
        buildJedisConnector in class BaseRedisDLock
        Returns:
        Since:
        0.1.1.2
      • getJedis

        protected redis.clients.jedis.Jedis getJedis()
        Returns:
      • lock

        public LockResult lock​(int waitWeight,
                               String clientId,
                               long lockDurationMs)
        Acquire the lock for clientId for a duration of lockDurationMs.

        Reentrant: lock can be acquired multiple times by the same clientId. Lock's expiry will be extended accordingly.

        Parameters:
        waitWeight - "fairness": clientId with higher waitWeight value might have higher chance to acquire the lock, negative value means "no fairness"
        clientId - within a namespace, only one client is allowed to hold the lock as a given time
        Returns:
        LockResult.SUCCESSFUL if successful, LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently hold by another client