<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<phpdoc:classref xml:id="class.mongodb-driver-readpreference" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">

 <title>The MongoDB\Driver\ReadPreference class</title>
 <titleabbrev>MongoDB\Driver\ReadPreference</titleabbrev>

 <partintro>

<!-- {{{ MongoDB\Driver\ReadPreference intro -->
  <section xml:id="mongodb-driver-readpreference.intro">
   &reftitle.intro;
   <para>

   </para>
  </section>
<!-- }}} -->

  <section xml:id="mongodb-driver-readpreference.synopsis">
   &reftitle.classsynopsis;

<!-- {{{ Synopsis -->
   <classsynopsis>
    <ooclass><classname>MongoDB\Driver\ReadPreference</classname></ooclass>

<!-- {{{ Class synopsis -->
    <classsynopsisinfo>
     <modifier>final</modifier>
     <ooclass>
      <classname>MongoDB\Driver\ReadPreference</classname>
     </ooclass>

     <oointerface>
      <interfacename>MongoDB\BSON\Serializable</interfacename>
     </oointerface>

     <oointerface>
      <interfacename>Serializable</interfacename>
     </oointerface>
    </classsynopsisinfo>
<!-- }}} -->
    <classsynopsisinfo role="comment">&Constants;</classsynopsisinfo>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.rp-primary">MongoDB\Driver\ReadPreference::RP_PRIMARY</varname>
     <initializer>1</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.rp-primary-preferred">MongoDB\Driver\ReadPreference::RP_PRIMARY_PREFERRED</varname>
     <initializer>5</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.rp-secondary">MongoDB\Driver\ReadPreference::RP_SECONDARY</varname>
     <initializer>2</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.rp-secondary-preferred">MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED</varname>
     <initializer>6</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.rp-nearest">MongoDB\Driver\ReadPreference::RP_NEAREST</varname>
     <initializer>10</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>string</type>
     <varname linkend="mongodb-driver-readpreference.constants.primary">MongoDB\Driver\ReadPreference::PRIMARY</varname>
     <initializer>primary</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>string</type>
     <varname linkend="mongodb-driver-readpreference.constants.primary-preferred">MongoDB\Driver\ReadPreference::PRIMARY_PREFERRED</varname>
     <initializer>primaryPreferred</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>string</type>
     <varname linkend="mongodb-driver-readpreference.constants.secondary">MongoDB\Driver\ReadPreference::SECONDARY</varname>
     <initializer>secondary</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>string</type>
     <varname linkend="mongodb-driver-readpreference.constants.secondary-preferred">MongoDB\Driver\ReadPreference::SECONDARY_PREFERRED</varname>
     <initializer>secondaryPreferred</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>string</type>
     <varname linkend="mongodb-driver-readpreference.constants.nearest">MongoDB\Driver\ReadPreference::NEAREST</varname>
     <initializer>nearest</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.no-max-staleness">MongoDB\Driver\ReadPreference::NO_MAX_STALENESS</varname>
     <initializer>-1</initializer>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>const</modifier>
     <type>int</type>
     <varname linkend="mongodb-driver-readpreference.constants.smallest-max-staleness-seconds">MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS</varname>
     <initializer>90</initializer>
    </fieldsynopsis>

    <classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongodb-driver-readpreference')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
   </classsynopsis>
<!-- }}} -->

  </section>

<!-- {{{ MongoDB\Driver\ReadPreference constants -->
  <section xml:id="mongodb-driver-readpreference.constants">
   &reftitle.constants;
   <variablelist>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.rp-primary">
     <term><constant>MongoDB\Driver\ReadPreference::RP_PRIMARY</constant></term>
     <listitem>
      <para>
       All operations read from the current replica set primary. This is the
       default read preference for MongoDB.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.rp-primary-preferred">
     <term><constant>MongoDB\Driver\ReadPreference::RP_PRIMARY_PREFERRED</constant></term>
     <listitem>
      <para>
       In most situations, operations read from the primary but if it is
       unavailable, operations read from secondary members.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.rp-secondary">
     <term><constant>MongoDB\Driver\ReadPreference::RP_SECONDARY</constant></term>
     <listitem>
      <para>
       All operations read from the secondary members of the replica set.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.rp-secondary-preferred">
     <term><constant>MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED</constant></term>
     <listitem>
      <para>
       In most situations, operations read from secondary members but if no
       secondary members are available, operations read from the primary.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.rp-nearest">
     <term><constant>MongoDB\Driver\ReadPreference::RP_NEAREST</constant></term>
     <listitem>
      <para>
       Operations read from member of the replica set with the least network
       latency, irrespective of the member&apos;s type.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.primary">
     <term><constant>MongoDB\Driver\ReadPreference::PRIMARY</constant></term>
     <listitem>
      <para>
       All operations read from the current replica set primary. This is the
       default read preference for MongoDB.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.primary-preferred">
     <term><constant>MongoDB\Driver\ReadPreference::PRIMARY_PREFERRED</constant></term>
     <listitem>
      <para>
       In most situations, operations read from the primary but if it is
       unavailable, operations read from secondary members.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.secondary">
     <term><constant>MongoDB\Driver\ReadPreference::SECONDARY</constant></term>
     <listitem>
      <para>
       All operations read from the secondary members of the replica set.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.secondary-preferred">
     <term><constant>MongoDB\Driver\ReadPreference::SECONDARY_PREFERRED</constant></term>
     <listitem>
      <para>
       In most situations, operations read from secondary members but if no
       secondary members are available, operations read from the primary.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.nearest">
     <term><constant>MongoDB\Driver\ReadPreference::NEAREST</constant></term>
     <listitem>
      <para>
       Operations read from member of the replica set with the least network
       latency, irrespective of the member&apos;s type.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.no-max-staleness">
     <term><constant>MongoDB\Driver\ReadPreference::NO_MAX_STALENESS</constant></term>
     <listitem>
      <para>
       The default value for the <literal>"maxStalenessSeconds"</literal>
       option is to specify no limit on maximum staleness, which means that the
       driver will not consider a secondary&apos;s lag when choosing where to
       direct a read operation.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry xml:id="mongodb-driver-readpreference.constants.smallest-max-staleness-seconds">
     <term><constant>MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS</constant></term>
     <listitem>
      <para>
       The minimum value for the <literal>"maxStalenessSeconds"</literal> option
       is 90 seconds. The driver estimates secondaries&apos; 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.
      </para>
     </listitem>
    </varlistentry>

   </variablelist>
  </section>
<!-- }}} -->

  <section role="changelog">
   &reftitle.changelog;
   <para>
    <informaltable>
     <tgroup cols="2">
      <thead>
       <row>
        <entry>&Version;</entry>
        <entry>&Description;</entry>
       </row>
      </thead>
      <tbody>
       <row>
        <entry>PECL mongodb 1.7.0</entry>
        <entry>
         <para>
          Added the
          <constant>MongoDB\Driver\ReadPreference::PRIMARY</constant>,
          <constant>MongoDB\Driver\ReadPreference::PRIMARY_PREFERRED</constant>,
          <constant>MongoDB\Driver\ReadPreference::SECONDARY</constant>,
          <constant>MongoDB\Driver\ReadPreference::SECONDARY_PREFERRED</constant>,
          <constant>MongoDB\Driver\ReadPreference::NEAREST</constant> constants.
         </para>
         <para>
          Implements <interfacename>Serializable</interfacename>.
         </para>
        </entry>
       </row>
       <row>
        <entry>PECL mongodb 1.2.0</entry>
        <entry>
         <para>
          Added the
          <constant>MongoDB\Driver\ReadPreference::NO_MAX_STALENESS</constant>
          and
          <constant>MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS</constant>
          constants.
         </para>
         <para>
          Implements <interfacename>MongoDB\BSON\Serializable</interfacename>.
         </para>
        </entry>
       </row>
      </tbody>
     </tgroup>
    </informaltable>
   </para>
  </section>

 </partintro>

 &reference.mongodb.mongodb.driver.entities.readpreference;

</phpdoc:classref>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
