MongoDB\Driver\Manager::startSession

(mongodb >=1.4.0)

MongoDB\Driver\Manager::startSessionStart a new client session for use with this client

Descrição

final public MongoDB\Driver\Manager::startSession(?array $options = null): MongoDB\Driver\Session

Creates a MongoDB\Driver\Session for the given options. The session may then be specified when executing commands, queries, and write operations.

Nota: A MongoDB\Driver\Session can only be used with the MongoDB\Driver\Manager from which it was created.

Parâmetros

options

options
Option Type Description Default
causalConsistency bool

Configure causal consistency in a session. If true, each operation in the session will be causally ordered after the previous read or write operation. Set to false to disable causal consistency.

See » Casual Consistency in the MongoDB manual for more information.

true
defaultTransactionOptions array

Default options to apply to newly created transactions. These options are used unless they are overridden when a transaction is started with different value for each option.

options
Option Type Description
maxCommitTimeMS integer

A quantidade máxima de tempo em milissegundos para permitir que um único comando commitTransaction seja executado.

Se especificada, maxCommitTimeMS deve ser um inteiro de 32 bits com sinal com valor maior ou igual a zero.

readConcern MongoDB\Driver\ReadConcern

Um read concern a ser aplicado à operação.

Esta opção está disponível no MongoDB 3.2+ e resultará em uma exceção em tempo de execução se for especificada para uma versão de servidor mais antiga.

readPreference MongoDB\Driver\ReadPreference

Uma preferência de leitura a ser usada para selecionar um servidor para a operação.

writeConcern MongoDB\Driver\WriteConcern

Um write concern a ser aplicado à operação.

This option is available in MongoDB 4.0+.

[]
snapshot bool

Configure snapshot reads in a session. If true, a timestamp will be obtained from the first supported read operation in the session (i.e. find, aggregate, or unsharded distinct). Subsequent read operations within the session will then utilize a "snapshot" read concern level to read majority-committed data from that timestamp. Set to false to disable snapshot reads.

Snapshot reads require MongoDB 5.0+ and cannot be used with causal consistency, transactions, or write operations. If "snapshot" is true, "causalConsistency" will default to false.

See » Read Concern "snapshot" in the MongoDB manual for more information.

false

Valor Retornado

Returns a MongoDB\Driver\Session.

Erros/Exceções

Registro de Alterações

Versão Descrição
PECL mongodb 1.11.0

The "snapshot" option was added.

PECL mongodb 1.6.0

The "maxCommitTimeMS" option was added to "defaultTransactionOptions".

PECL mongodb 1.5.0

The "defaultTransactionOptions" option was added.

Veja Também

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top