def observe_and_wait(*keys, &block)
      options = {:timeout => default_observe_timeout}
      options.update(keys.pop) if keys.size > 1 && keys.last.is_a?(Hash)
      verify_observe_options(options)
      raise ArgumentError, "at least one key is required" if keys.empty?
      key_cas = if keys.size == 1 && keys[0].is_a?(Hash)
                  keys[0]
                else
                  keys.flatten.each_with_object({}) do |kk, h|
                    h[kk] = nil # set CAS to nil
                  end
                end
      res = do_observe_and_wait(key_cas, options, &block) while res.nil?
      return res.values.first if keys.size == 1 && (keys[0].is_a?(String) || keys[0].is_a?(Symbol))
      return res
    end
def observe_and_wait(*keys, &block)
      options = {:timeout => default_observe_timeout}
      options.update(keys.pop) if keys.size > 1 && keys.last.is_a?(Hash)
      verify_observe_options(options)
      raise ArgumentError, "at least one key is required" if keys.empty?
      key_cas = if keys.size == 1 && keys[0].is_a?(Hash)
                  keys[0]
                else
                  keys.flatten.each_with_object({}) do |kk, h|
                    h[kk] = nil # set CAS to nil
                  end
                end
      res = do_observe_and_wait(key_cas, options, &block) while res.nil?
      return res.values.first if keys.size == 1 && (keys[0].is_a?(String) || keys[0].is_a?(Symbol))
      return res
    end
Wait for persistence condition

 @since 1.2.0.dp6

 This operation is useful when some confidence needed regarding the
 state of the keys. With two parameters +:replicated+ and +:persisted+
 it allows to set up the waiting rule.

 @param [String, Symbol, Array, Hash] keys The list of the keys to
   observe. Full form is hash with key-cas value pairs, but there are
   also shortcuts like just Array of keys or single key. CAS value
   needed to when you need to ensure that the storage persisted exactly
   the same version of the key you are asking to observe.
 @param [Hash] options The options for operation
 @option options [Fixnum] :timeout The timeout in microseconds
 @option options [Fixnum] :replicated How many replicas should receive
   the copy of the key.
 @option options [Fixnum] :persisted How many nodes should store the
   key on the disk.

 @raise [Couchbase::Error::Timeout] if the given time is up

 @return [Fixnum, Hash<String, Fixnum>] will return CAS value just like
   mutators or pairs key-cas in case of multiple keys.