@@ -20,9 +20,9 @@ Specify How CRUD Operations Run on Replica Sets
20
20
Overview
21
21
--------
22
22
23
- In this guide, you can learn how to use the **write concern**, **read concern**, and
24
- **read preference** configurations to modify the way that MongoDB runs
25
- create, read, update, and delete (CRUD) operations on replica sets.
23
+ In this guide, you can learn how to configure **write concern**, **read concern**,
24
+ and **read preference** options to modify the way that the {+php-library+} runs create,
25
+ read, update, and delete (CRUD) operations on replica sets.
26
26
27
27
You can set write concern, read concern, and read preference options at the following
28
28
levels:
@@ -35,10 +35,15 @@ levels:
35
35
36
36
This list also indicates the increasing order of precedence of the option settings. For
37
37
example, if you set a read concern level for a transaction, it will override a read
38
- concern level set for the client.
38
+ concern level inherited from the client.
39
39
40
40
These options allow you to customize the causal consistency and availability of the data
41
- in your replica sets.
41
+ in your replica sets. To see a full list of read preference, read concern, and write concern
42
+ options, see the following guides in the {+mdb-server+} manual:
43
+
44
+ - :manual:`Read Preference </core/read-preference/>`
45
+ - :manual:`Read Concern </reference/read-concern/>`
46
+ - :manual:`Write Concern </reference/write-concern/>`
42
47
43
48
.. _php-read-write-config:
44
49
@@ -47,11 +52,11 @@ Configure Read and Write Operations
47
52
48
53
You can control how the library routes read operations by setting a read preference.
49
54
You can also control how the library waits for acknowledgment of read and write operations
50
- on a replica set by setting a read and write concern .
55
+ on a replica set by setting read and write concerns .
51
56
52
57
This section shows how to configure the read preference, read concern, and write
53
- concern at various levels by passing an options array parameter to the following
54
- methods:
58
+ concern at various levels by passing an options array parameter to any one of the
59
+ following methods:
55
60
56
61
- :ref:`MongoDB\Client::__construct() <php-read-write-client>`: Configures client-level
57
62
settings
@@ -96,6 +101,14 @@ URI, which is passed as a parameter to the ``MongoDB\Client`` constructor:
96
101
:start-after: start-client-settings-uri
97
102
:end-before: end-client-settings-uri
98
103
104
+ .. note::
105
+
106
+ The ``readPreference``, ``readConcernLevel``, and ``w`` client options accept
107
+ string values. When configuring read and write settings at any other level,
108
+ you must assign values of type ``MongoDB\Driver\ReadPreference``,
109
+ ``MongoDB\Driver\ReadConcern``, and ``MongoDB\Driver\WriteConcern`` to the corresponding
110
+ options.
111
+
99
112
.. _php-read-write-session:
100
113
101
114
Session Configuration
@@ -113,7 +126,6 @@ method. The code configures the following settings:
113
126
- ``MAJORITY`` write concern: The majority of all replica set members
114
127
must acknowledge the write operation
115
128
116
-
117
129
.. literalinclude:: /includes/read-write-pref.php
118
130
:language: php
119
131
:dedent:
@@ -203,7 +215,7 @@ settings in the following ways:
203
215
Tag Sets
204
216
~~~~~~~~
205
217
206
- In {+mdb-server+}, you can apply key-value :manual:`tags
218
+ The {+mdb-server+} allows you to apply key-value :manual:`tags
207
219
</core/read-preference-tags/>` to replica-set
208
220
members according to any criteria you choose. You can then use
209
221
those tags to target one or more members for a read operation.
@@ -214,19 +226,20 @@ pass them as a parameter to your ``MongoDB\Driver\ReadPreference`` class
214
226
constructor. Then, set the ``MongoDB\Driver\ReadPreference`` object as
215
227
the value of the ``readPreference`` database option.
216
228
217
- This code example sets the ``readPreference`` option to a tag set
218
- that instructs ``test_database`` to prefer reads from secondary replica set
219
- members in the following order:
229
+ Suppose you are connected to a replica set that contains members hosted
230
+ at multiple data centers across the United States. This code example sets
231
+ the ``readPreference`` option to a tag set that instructs ``test_database``
232
+ to prefer reads from secondary replica set members in the following order:
220
233
221
234
1. Members from the New York data center (``['dc' => 'ny']``)
222
235
#. Members from the San Francisco data center (``['dc' => 'sf']``)
223
236
#. Any secondary members (``[]``)
224
237
225
238
.. literalinclude:: /includes/databases-collections/databases-collections.php
226
- :language: php
227
- :dedent:
228
- :start-after: start-tag-set
229
- :end-before: end-tag-set
239
+ :language: php
240
+ :dedent:
241
+ :start-after: start-tag-set
242
+ :end-before: end-tag-set
230
243
231
244
.. _php-local-threshold:
232
245
0 commit comments