Created
May 3, 2013 16:38
-
-
Save jmikola/5510920 to your computer and use it in GitHub Desktop.
Testing awaitData and tailable cursors against mongod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$m = new MongoClient(); | |
$m->test->foo->drop(); | |
$m->test->createCollection('foo', ['capped' => true, 'size' => 67108864]); | |
$c = $m->test->foo; | |
$c->insert(['x' => 1]); | |
$cursor = $c->find()->awaitData()->tailable(); | |
while (1) { | |
if (!$cursor->hasNext()) { | |
if ($cursor->dead()) { | |
break; | |
} | |
// optionally sleep a few seconds before re-polling | |
continue; | |
} | |
var_dump($cursor->getNext()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment