MongoDB\Driver\ReadPreference::getMaxStalenessSeconds

(mongodb >=1.2.0)

MongoDB\Driver\ReadPreference::getMaxStalenessSecondsReturns the ReadPreference's "maxStalenessSeconds" option

说明

final public MongoDB\Driver\ReadPreference::getMaxStalenessSeconds ( void ) : int

参数

此函数没有参数。

返回值

Returns the ReadPreference's "maxStalenessSeconds" option. If no max staleness has been specified, MongoDB\Driver\ReadPreference::NO_MAX_STALENESS will be returned.

错误/异常

范例

Example #1 MongoDB\Driver\ReadPreference::getMaxStalenessSeconds() example

<?php

$rp 
= new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY);
var_dump($rp->getMaxStalenessSeconds());

$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARYnull, [
    
'maxStalenessSeconds' => MongoDB\Driver\ReadPreference::NO_MAX_STALENESS,
]);
var_dump($rp->getMaxStalenessSeconds());

$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARYnull, [
    
'maxStalenessSeconds' => MongoDB\Driver\ReadPreference::SMALLEST_MAX_STALENESS_SECONDS,
]);
var_dump($rp->getMaxStalenessSeconds());

$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARYnull, [
    
'maxStalenessSeconds' => 1000,
]);
var_dump($rp->getMaxStalenessSeconds());

?>

以上例程会输出:

int(-1)
int(-1)
int(90)
int(1000)
相关文章
php mongodb driver the mongodb driver readpreference classphp mongodb driver cursor returns an array containing all results for this cursorphp mongodb driver monitoring commandfailedevent returns the command namephp mongodb driver monitoring commandfailedevent returns the command s duration in microsecondsphp mongodb driver monitoring commandfailedevent returns the exception associated with the failed commandphp mongodb driver monitoring commandsucceededevent returns the command namephp mongodb driver monitoring commandsucceededevent returns the command s duration in microsecondsphp mongodb driver readconcern returns the readconcern s level optionphp mongodb driver readpreference returns an object for bson serializationphp mongodb driver readpreference returns the readpreference s maxstalenessseconds optionphp mongodb driver readpreference returns the readpreference s mode optionphp mongodb driver readpreference returns the readpreference s tagsets optionphp mongodb driver exception runtimeexception returns whether an error label is associated with an exceptionphp mongodb driver writeconcern returns the writeconcern s journal optionphp mongodb driver writeconcern returns the writeconcern s w optionphp mongodb driver writeconcern returns the writeconcern s wtimeout optionphp mongodb driver writeerror returns additional metadata for the writeerrorphp mongodb driver writeerror returns the writeerror s error messagephp mongodb driver exception writeexception returns the writeresult for the failed write operationphp mongodb driver writeresult returns the number of documents deleted
关注编程学问公众号