When the mongodb pointer expires

I don’t have knowledge about Mongodba, and I just want to ask if something is possible and, if possible, how it can be done. My question is how to find out when the cursor expires. Is there any API for this purpose?

I would be grateful for any comments and recommendations.

Sincerely.

+3
source share
3 answers

From the MongoDB documentation:

By default, MongoDB automatically closes the cursor when the client has exhausted all the results in the cursor. However, for private collections, you can use the Tailable Cursor, which remains open after the client runs out of results in the original cursor.

http://docs.mongodb.org/manual/tutorial/create-tailable-cursor/

, , batchSize timeout. , , , :

+3

"" ( 10 ) , .

"" , Java NoTimeout:

dbcoll.find(...).addOption(Bytes.QUERYOPTION_NOTIMEOUT) 

, , .

http://api.mongodb.org/java/current/com/mongodb/Bytes.html#QUERYOPTION_NOTIMEOUT

+1

, pymongo: CursorNotFound: Cursor not found, cursor id. , , , pymongo .

FAQ pymongo : .

- , , .

client = MongoClient("localhost")
db = client.testdatabase
cursor = db.testcollection.find({}, no_cursor_timeout=True)

find() , :

cursor_type (): . CursorType:

  • NON_TAILABLE - .
  • TAILABLE - - . , , , . . . .
  • TAILABLE_AWAIT - . , , .
  • EXHAUST - the result of this search will be the exhaust cursor. MongoDB will transmit the results to the client, without waiting for the client to request each batch, reducing latency. See notes to below.

Update: after use, no_cursor_timeoutI was wondering what happened to the cursor when they were not executed. Here is the answer: PyMongo: what happens to the cursor when no_cursor_timeout = True

0
source

All Articles