MongoClient::killCursor PHP 메소드

killCursor() 공개 메소드

Kills a specific cursor on the server
public killCursor ( string $serverHash, integer | mongoint64 $id ) : boolean
$serverHash string - The server hash that has the cursor. This can be obtained through MongoCursor::info.
$id integer | mongoint64 - The ID of the cursor to kill. You can either supply an int containing the 64 bit cursor ID, or an object of the MongoInt64 class. The latter is necessary on 32 bit platforms (and Windows).
리턴 boolean - Returns TRUE if the method attempted to kill a cursor, and FALSE if there was something wrong with the arguments (such as a wrong server_hash). The return status does not reflect where the cursor was actually killed as the server does not provide that information.
    public function killCursor($serverHash, $id)
    {
        // since we currently support just single server connection,
        // the $serverHash arg is ignored
        if ($id instanceof MongoInt64) {
            $id = $id->value;
        } elseif (!is_numeric($id)) {
            return false;
        }
        $this->protocols[$serverHash]->opKillCursors([(int) $id], [], MongoCursor::$timeout);
        return true;
    }

Usage Example

예제 #1
0
파일: mongo-core.php 프로젝트: isS/NoSQL
<?php

$mongoClient = new MongoClient("mongodb://whisky:13000/?replicaset=seta");
$connections = $mongoClient->getConnections();
foreach ($connections as $con) {
    if ($con['connection']['connection_type_desc'] == "SECONDARY") {
        echo "Closing '{$con['hash']}':";
        $a->close($con['hash']);
    }
}
$mongoClient->selectDB("foo");
$mongoClient->getHosts();
$m->setReadPreference(MongoClient::RP_SECONDARY, array(array('dc' => 'east', 'use' => 'reporting'), array('dc' => 'west'), array()));
var_dump($m->getReadPreference());
$cursor = $collections->find();
$result = $cursor->next();
$info = $cursor->info();
MongoClient::killCursor($info['server'], $info['id']);
var_dump($mongoClient->listDBs());
$c1 = $m->selectCollection("foo", "bar.baz");
$c2 = $m->selectDB("foo")->selectCollection("bar.baz");
var_dump(MongoClient::_toString);