ReactiveMongo是否有办法强制查询在奴隶上发生?
目前我正在使用slaveOk,但它不保证查询在slave上运行。
collection.find(query).options(QueryOpts().slaveOk)
slaveOk的文档:
/** Toggles SlaveOk: The query is might be run on a secondary. */
答案 0 :(得分:1)
Reactivemongo允许您在光标上设置读取首选项。
import reactivemongo.api.ReadPreference
collection.find(query).cursor[BSONDocument](ReadPreference.secondary)
有关不同阅读首选项的更多信息,请参阅mongodb文档:http://docs.mongodb.org/manual/core/read-preference/