PHP Doku:: Sets whether this cursor will be left open after fetching the last results - mongocursor.tailable.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverCore ClassesThe MongoCursor classMongoCursor::tailable

Ein Service von Reinhard Neidl - Webprogrammierung.

The MongoCursor class

<<MongoCursor::sort

MongoCursor::timeout>>

MongoCursor::tailable

(PECL mongo >=0.9.4)

MongoCursor::tailableSets whether this cursor will be left open after fetching the last results

Beschreibung

public MongoCursor MongoCursor::tailable ([ boolean $tail = true ] )

Mongo has a feature known as tailable cursors which are similar to the Unix "tail -f" command.

Tailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object's position. you can resume using the cursor later, from where it was located, if more data were received.

Like any "latent cursor", the cursor may become invalid at some point -- for example if that final object it references were deleted. Thus, you should be prepared to requery if the cursor is MongoCursor::dead().

Parameter-Liste

tail

If the cursor should be tailable.

Rückgabewerte

Returns this cursor.

Fehler/Exceptions

Throws MongoCursorException if this cursor has started iterating.

Beispiele

Beispiel #1 MongoCursor::tailable() example

<?php

$cursor 
$collection->find()->tailable();

$results = array();

while (
1) {
    if (!
$cursor->hasNext()) {
        
// we've read all the results, exit
        
if ($cursor->dead()) {
            break;
        }
        
// read all results so far, wait for more
        
sleep(10);
    }
    else {
        
$results[] = $cursor->getNext();
    }
}

?>

Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)