@@ -293,7 +293,8 @@ Read Preference
293293
294294Read preference determines the candidate :manual:`replica set</replication/>`
295295members to which a query or command can be sent. They consist of a **mode**
296- specified as a symbol, an array of hashes known as **tag_sets**, and two
296+ specified as a symbol, an array of hashes known as **tag_sets**,
297+ the ``hedge`` option, which is a Hash specifying hedged read behavior, and two
297298timing options: **local_threshold** and **server_selection_timeout**.
298299
299300``local_threshold``
@@ -378,6 +379,31 @@ A tag set that is an empty document matches any server, because
378379the empty tag set is a subset of any tag set. This means the default
379380``tag_sets`` parameter ``[{}]`` matches all servers.
380381
382+ Hedge
383+ ~~~~~
384+
385+ The ``hedge`` parameter is a Hash that specifies whether the server should use
386+ hedged reads. With hedged reads, sharded clusters can route read operations to
387+ two replica set members and return results from the first respondent.
388+
389+ The ``hedge`` option may only be specified on non-primary read preferences. It
390+ must be provided as Hash with the key ``enabled`` set to ``true`` or ``false``.
391+
392+ .. code-block:: ruby
393+
394+ client = Mongo::Client.new(
395+ [ '127.0.0.1:27017' ],
396+ read: { mode: :secondary, hedge: { enabled: true } },
397+ )
398+
399+ See the :manual:`MongoDB Manual </core/read-preference-hedge-option>` for
400+ more information about hedged reads.
401+
402+ .. note::
403+
404+ The ``hedge`` option is only available on MongoDB server versions 4.4 and newer.
405+ Attempting to use this option on older server versions will result in an error.
406+
381407.. _ruby-driver-updating:
382408
383409Updating
0 commit comments