php slaveokay 设置,MongoCursor::slaveOkay

说明

public MongoCursor MongoCursor::slaveOkay

([ bool $okay = true

] )

Warning

This method is deprecated since version 1.5.0. Instead, please use

MongoCursor::setReadPreference() and 读取首选项.

Calling this will make the driver route reads to secondaries if:

You are using a replica set, and

You created a MongoClient instance using the option

"replicaSet" => "setName", and

There is a healthy secondary that can be reached by the driver.

You can check which server was used for this query by calling

MongoCursor::info() after running the query. It's

server field will show which server the query was sent to.

Note that you should use this function even if you do not use the automatic

routing to secondaries. If you connect directly to a secondary in a replica

set, you still need to call this function, which basically tells the database

that you are aware that you might be getting older data and you're okay with

that. If you do not call this, you'll get "not master" errors when you try to

query.

This method will override the static class variable

MongoCursor::$slaveOkay. It will also override

Mongo::setSlaveOkay(),

MongoDB::setSlaveOkay() and

MongoCollection::setSlaveOkay().

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值