The MongoDB\Driver\ReadPreference class
(mongodb >=1.0.0)
Introduction
Class synopsis
$mode
[, array $tagSets
= NULL
[, array $options
= array()
]] )Predefined Constants
MongoDB\Driver\ReadPreference::RP_PRIMARY
-
All operations read from the current replica set primary. This is the default read preference for MongoDB.
MongoDB\Driver\ReadPreference::RP_PRIMARY_PREFERRED
-
In most situations, operations read from the primary but if it is unavailable, operations read from secondary members.
MongoDB\Driver\ReadPreference::RP_SECONDARY
-
All operations read from the secondary members of the replica set.
MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED
-
In most situations, operations read from secondary members but if no secondary members are available, operations read from the primary.
MongoDB\Driver\ReadPreference::RP_NEAREST
-
Operations read from member of the replica set with the least network latency, irrespective of the member's type.
MongoDB\Driver\ReadPreference::NO_MAX_STALENESS
-
The default value for the "maxStalenessSeconds" option is to specify no limit on maximum staleness, which means that the driver will not consider a secondary's lag when choosing where to direct a read operation.
MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS
-
The minimum value for the "maxStalenessSeconds" option is 90 seconds. The driver estimates secondaries' staleness by periodically checking the latest write date of each replica set member. Since these checks are infrequent, the staleness estimate is coarse. Thus, the driver cannot enforce a max staleness value of less than 90 seconds.
Changelog
Version | Description |
---|---|
1.2.0 |
Added the
Implements MongoDB\BSON\Serializable. |
Table of Contents
- MongoDB\Driver\ReadPreference::bsonSerialize — Returns an object for BSON serialization
- MongoDB\Driver\ReadPreference::__construct — Create a new ReadPreference
- MongoDB\Driver\ReadPreference::getMaxStalenessSeconds — Returns the ReadPreference's "maxStalenessSeconds" option
- MongoDB\Driver\ReadPreference::getMode — Returns the ReadPreference's "mode" option
- MongoDB\Driver\ReadPreference::getTagSets — Returns the ReadPreference's "tagSets" option
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-class.mongodb-driver-readpreference.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.