I'm attempting to set all incoming read queries to hit slaves on my mongo servers.
I see in the PHP docs a reference to:
MongoCursor::$slaveOkay = true;
However, this just seems to setup queries to be fired off to slaves; not really to do anything else. My connections to my servers look like this:
$mongo = new Mongo("mongodb://my.server:27017",
array("replicaSet" => 'replicaSet', "persist" => "pool")
);
Will I need to do anything different with my persist connection when wanting to only connect to the slave for reads?
How can I target queries to hit just the Slave so that the writes I have on the primary won't block incoming read requests.
PHP docs shows me this example:
$db->setSlaveOkay(true);
$c = $db->myCollection;
$cursor = $c->find();
However I'm confused at the difference this has between the above, and if both are needed or not.