@Override
    public BaseRedisDLock init() {
        super.init();

        /*
         * Parse custom property: redis-password
         */
        String password = getLockProperty(LOCK_PROP_REDIS_PASSWORD);
        if (!StringUtils.isBlank(password)) {
            this.redisPassword = password;
        }

        if (jedisConnector == null) {
            jedisConnector = buildJedisConnector();
            myOwnRedis = jedisConnector != null;
        }

        /*
         * Implementation: firstly get the current client-id value; if not null
         * AND not equal to the supplied-client-id then return nil, otherwise
         * write the supplied-client-id.
         * 
         * Parameters: (1) key name, (2) supplied-client-id, (3) TTL in
         * milliseconds.
         * 
         * Return: (1) nil if lock is currently hold by another client, (2)
         * non-nil if successful.
         */
        scriptLock = "local cval=redis.call(\"get\", ARGV[1]);"
                + " if cval and cval~=ARGV[2] then return nil"
                + " else return redis.call(\"set\", ARGV[1], ARGV[2], \"PX\", ARGV[3]); end";

        /*
         * Implementation: firstly get the current client-id value; if not null
         * AND not equal to the supplied-client-id then return nil, otherwise
         * delete the key.
         * 
         * Parameters: (1) key name, (2) supplied-client-id.
         * 
         * Return: (1) nil if lock is currently hold by another client, (2) "1"
         * if successful, (3) "0" if lock is not found
         */
        scriptUnlock = "local cval=redis.call(\"get\", ARGV[1]);"
                + " if cval and cval~=ARGV[2] then return nil"
                + " else return redis.call(\"del\", ARGV[1]); end";

        return this;
    }
@ Override public BaseRedisDLock init ( ) { super . init ( ) ; String password = getLockProperty ( LOCK_PROP_REDIS_PASSWORD ) ; if ( ! StringUtils . isBlank ( password ) ) { this . redisPassword = password ; } if ( jedisConnector == null ) { jedisConnector = buildJedisConnector ( ) ; myOwnRedis = jedisConnector != null ; } scriptLock = "local cval=redis.call(\"get\", ARGV[1]);" + " if cval and cval~=ARGV[2] then return nil" + " else return redis.call(\"set\", ARGV[1], ARGV[2], \"PX\", ARGV[3]); end" ; scriptUnlock = "local cval=redis.call(\"get\", ARGV[1]);" + " if cval and cval~=ARGV[2] then return nil" + " else return redis.call(\"del\", ARGV[1]); end" ; return this ; }
{@inheritDoc}