PHP.mk документација

Поврзувања

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

mongodb.connection-handling.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека mongodb.connection-handling.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Поврзувања

Референца за `mongodb.connection-handling.php` со подобрена типографија и навигација.

mongodb.connection-handling.php

Connection handling and persistence

Забелешка: On Unix platforms, the extension is sensitive to scripts that use the fork() system call without also calling exec(). Users are advised not to re-use MongoDB\Driver\Manager instances in a forked child process.

Connection and topology persistence (PHP version since 1.2.0)

All versions of the extension since 1.2.0 persist the Фрлено кога драјверот ќе наиде на грешка во време на извршување (на пр. внатрешна грешка од client object in the PHP worker process, which allows it to re-use database connections, authentication states, and topology information across multiple requests.

Кога MongoDB\Driver\Manager::__construct() is invoked, a hash is created from its arguments (i.e. URI string and array options). The extension will attempt to find a previously persisted Фрлено кога драјверот ќе наиде на грешка во време на извршување (на пр. внатрешна грешка од client object for that hash. If an existing client cannot be found for the hash, a new client will be created and persisted for future use. This behavior can be disabled via the "disableClientPersistence" driver option.

Each client contains its own database connections and a view of the server topology (e.g. standalone, replica set, shard cluster). By persisting the client between PHP requests, the extension is able to re-use established database connections and remove the need for » discovering the server topology on each request.

Consider the following example:

<?php

$managers
= [
new
MongoDB\Driver\Manager('mongodb://127.0.0.1'),
new
MongoDB\Driver\Manager('mongodb://127.0.0.1'),
new
MongoDB\Driver\Manager('mongodb://127.0.0.1:27017'),
new
MongoDB\Driver\Manager('mongodb://rs1.example.com,rs2.example.com/', ['replicaSet' => 'myReplicaSet']),
];

foreach (
$managers as $manager) {
$manager->executeCommand('test', new MongoDB\Driver\Command(['ping' => 1]));
}

?>

The first two Manager objects will share the same Фрлено кога драјверот ќе наиде на грешка во време на извршување (на пр. внатрешна грешка од client since their constructor arguments are identical. The third and fourth objects will each use their own client. In total, three clients will be created and the PHP worker executing this script will open two connections to 127.0.0.1 and one connection to each of rs1.example.com and rs2.example.com. If the extension discovers additional members of the replica set after issuing hello commands, it will open additional connections to those servers as well.

If the same worker executes the script again in a second request, the three clients will be re-used and no new connections will be made. Depending on how long ago the previous request was served, the extension may need to issue additional hello commands to update its view of the topologies.

Socket persistence (PHP versions before 1.2.0)

Versions of the extension before 1.2.0 utilize PHP's Streams API for database connections, using an API within Фрлено кога драјверот ќе наиде на грешка во време на извршување (на пр. внатрешна грешка од to designate custom handlers for socket communication; however, a new libmongoc client is created for each MongoDB\Driver\Manager. As a result, the extension persists individual database connections but not authentication state or topology information. This means that the extension needs to issue commands at the start of each request to authenticate and » discover the server topology.

Database connections are persisted by a hash derived from the server's host, port, and the URI string used to construct the MongoDB\Driver\Manager. The constructor's array options are not included in this hash.

Забелешка: Versions of the extension >= 1.1.8 and < 1.2.0 do not persist sockets for SSL connections. See » PHPC-720 за дополнителни информации.

Despite its shortcomings with persisting SSL connections when and topology information, this version of the extension supports all SSL опции за контекст since it uses PHP's Streams API.

Белешки од корисници

Нема белешки од корисници за оваа страница.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.