def lock(resource, ttl, options = {}, &block)
      lock_info = try_lock_instances(resource, ttl, options)

      if block_given?
        begin
          yield lock_info
          !!lock_info
        ensure
          unlock(lock_info) if lock_info
        end
      else
        lock_info
      end
    end
def lock(resource, ttl, options = {}, &block)
      lock_info = try_lock_instances(resource, ttl, options)

      if block_given?
        begin
          yield lock_info
          !!lock_info
        ensure
          unlock(lock_info) if lock_info
        end
      else
        lock_info
      end
    end
Create a distributed lock manager implementing redlock algorithm.
 Params:
 +servers+:: The array of redis connection URLs or Redis connection instances. Or a mix of both.
 +options+::
    * `retry_count`   being how many times it'll try to lock a resource (default: 3)
    * `retry_delay`   being how many ms to sleep before try to lock again (default: 200)
    * `retry_jitter`  being how many ms to jitter retry delay (default: 50)
    * `redis_timeout` being how the Redis timeout will be set in seconds (default: 0.1)
    * `time_source`   being a callable object returning a monotonic time in milliseconds
                      (default: see #default_time_source)
 Locks a resource for a given time.
 Params:
 +resource+:: the resource (or key) string to be locked.
 +ttl+:: The time-to-live in ms for the lock.
 +options+:: Hash of optional parameters
  * +extend+: A lock ("lock_info") to extend.
  * +extend_only_if_life+: If +extend+ is given, only acquire lock if currently held
 +block+:: an optional block to be executed; after its execution, the lock (if successfully
 acquired) is automatically unlocked.