(mongodb >=1.2.0)
MongoDB\Driver\ReadPreference::getMaxStalenessSeconds — 返回 ReadPreference 的“maxStalenessSeconds”选项
此函数没有参数。
返回 ReadPreference 的“maxStalenessSeconds”选项。如果未指定最大陈旧度,则将返回 MongoDB\Driver\ReadPreference::NO_MAX_STALENESS
。
示例 #1 MongoDB\Driver\ReadPreference::getMaxStalenessSeconds() 示例
<?php
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY);
var_dump($rp->getMaxStalenessSeconds());
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, [
'maxStalenessSeconds' => MongoDB\Driver\ReadPreference::NO_MAX_STALENESS,
]);
var_dump($rp->getMaxStalenessSeconds());
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, [
'maxStalenessSeconds' => MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS,
]);
var_dump($rp->getMaxStalenessSeconds());
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, [
'maxStalenessSeconds' => 1000,
]);
var_dump($rp->getMaxStalenessSeconds());
?>
上面的示例将输出
int(-1) int(-1) int(90) int(1000)