public function initSlave($point)
{
$this->db->{'local.oplog.$main'}->find(function ($cursor) {
$this->cursor = $cursor;
$cursor->state = 1;
$cursor->lastOpId = null;
foreach ($cursor->items as $k => &$item) {
if (\PHPDaemon\Core\Daemon::$config->logevents->value) {
\PHPDaemon\Core\Daemon::log(get_class($this) . ': caught oplog-record with ts = (' . \PHPDaemon\Core\Debug::dump($item['ts']) . ')');
}
$cursor->lastOpId = $item['ts'];
if ($item['op'] === 'i') {
$this->cacheObject($item['o']);
} elseif ($item['op'] === 'd') {
$this->deleteObject($item['o']);
} elseif ($item['op'] === 'u') {
if (isset($item['b']) && $item['b'] === false) {
$item['o']['_id'] = $item['o2']['_id'];
$this->cacheObject($item['o']);
} else {
$cursor->appInstance->{$item['ns']}->findOne(function ($item) {
$this->cacheObject($item);
}, ['where' => ['_id' => $item['o2']['_id']]]);
}
}
unset($cursor->items[$k]);
}
}, ['tailable' => true, 'sort' => ['$natural' => 1], 'snapshot' => 1, 'where' => ['ts' => ['$gt' => $point], '$exists' => ['_key' => true]], 'parse_oplog' => true]);
}