MongoClient::getReplSetInfo PHP Метод

getReplSetInfo() приватный Метод

This will be cached in APC (if available) for up to REPL_SET_CACHE_LIFETIME seconds, so servers are not spammed with getReplSetStatus calls, which appear to really slow down a MongoDB server when they happen frequently.
private getReplSetInfo ( ) : array
Результат array
    private function getReplSetInfo()
    {
        $primary_protocol = $this->connectToReplSetPrimary();
        // Make sure we have a conection to the PRIMARY
        $cache_key = "mongofill:replSetInfo:{$primary_protocol->getServerHash()}:" . __FILE__;
        $result = MONGOFILL_USE_APC ? apc_fetch($cache_key) : false;
        if (!$result) {
            // Temporarily enforce PRIMARY read because we need this collection to come from  the
            // PRIMARY server which we have already established a connection to.
            $configured_read_preference = $this->getReadPreference();
            $this->setReadPreference(static::RP_PRIMARY);
            $conf = $this->selectDB('local')->selectCollection('system.replset')->findOne();
            $this->readPreference = $configured_read_preference;
            // Set our RP back directly, bypass setReadPreference()
            // This will use the write protocol which is already established as the PRIMARY
            $status = $this->selectDB('admin')->command(['replSetGetStatus' => 1]);
            $result = ['ok' => 1, 'retval' => ['conf' => $conf, 'status' => $status]];
            if (MONGOFILL_USE_APC) {
                apc_store($cache_key, $result, self::REPL_SET_CACHE_LIFETIME);
            }
        }
        return $result;
    }