Skip to content

Commit 63e1d17

Browse files
author
Dave
authored
DOCSP-12298 cursor maxAwaitTimeMS (#494)
* DOCSP-12298 Cursor maxAwaitTimeMS * Staging updates * Staging updates * Review feedback * Staging fixes * Staging fixes * Review feedback * Staging Fixes * Staging Fixes * Review feedback * Review feedback
1 parent 049991a commit 63e1d17

File tree

4 files changed

+102
-12
lines changed

4 files changed

+102
-12
lines changed

source/core/tailable-cursors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _tailable-cursors-landing-page:
2+
13
================
24
Tailable Cursors
35
================
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.. _cursor-maxAwaitTimeMS:
2+
3+
=======================
4+
cursor.maxAwaitTimeMS()
5+
=======================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. method:: cursor.maxAwaitTimeMS(<time limit>)
19+
20+
.. include:: /includes/fact-mongosh-shell-method.rst
21+
22+
Specifies the maximum time for the server to wait for new documents
23+
that match a :ref:`tailable cursor <tailable-cursors-landing-page>`
24+
query on a :ref:`capped collection <manual-capped-collection>`. For
25+
more information on iterating a cursor returned by a query, see:
26+
:ref:`read-operations-cursors`.
27+
28+
The :method:`~cursor.maxAwaitTimeMS()` method has the following
29+
prototype form:
30+
31+
.. code-block:: javascript
32+
33+
db.collection.find(
34+
{ <query> },
35+
{ <projection> }
36+
).tailable( { awaitData: true } ).maxAwaitTimeMS( <milliseconds> )
37+
38+
The :method:`~cursor.maxAwaitTimeMS()` method has the following
39+
parameter:
40+
41+
.. list-table::
42+
:header-rows: 1
43+
:widths: 20 20 80
44+
45+
* - Parameter
46+
- Type
47+
- Description
48+
49+
* - ``milliseconds``
50+
- integer
51+
- Specifies a maximum wait time for new documents.
52+
53+
.. important::
54+
55+
This method, :method:`~cursor.maxAwaitTimeMS()`, sets a limit on how
56+
long a :ref:`tailable cursor <tailable-cursors-landing-page>` waits
57+
for the next response. :method:`~cursor.maxTimeMS()` sets a limit on
58+
total processing time.
59+
60+
Example
61+
--------
62+
63+
Query the :ref:`capped <manual-capped-collection>` ``sales`` collection
64+
to find agent Mary Kay's weekly sales totals:
65+
66+
.. code-block:: javascript
67+
:emphasize-lines: 4
68+
69+
db.sales.find(
70+
{ agent: "Mary Kay" },
71+
{ _id: 0, agent: 1, weeklyTotal: 1 }
72+
).tailable( { awaitData: true } ).maxAwaitTimeMS( 1000 )
73+
74+
The highlighted line creates a :ref:`tailable cursor
75+
<tailable-cursors-landing-page>` on the ``sales`` collection. The
76+
:method:`~cursor.maxAwaitTimeMS()` sets a one second maximum wait time
77+
for the next cursor update.
78+

source/reference/method/cursor.maxTimeMS.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,36 @@ Definition
1515

1616
.. method:: cursor.maxTimeMS(<time limit>)
1717

18-
1918
.. include:: /includes/fact-mongosh-shell-method.rst
2019

21-
2220
Specifies a cumulative time limit in milliseconds for processing
2321
operations on a cursor.
2422

23+
The :method:`~cursor.maxTimeMS()` method has the following prototype
24+
form:
25+
26+
.. code-block:: javascript
27+
28+
db.collection.find(
29+
{ <query> },
30+
{ <projection> }
31+
).maxTimeMS( <milliseconds> )
32+
2533
The :method:`~cursor.maxTimeMS()` method has the following
2634
parameter:
2735

28-
2936
.. list-table::
3037
:header-rows: 1
3138
:widths: 20 20 80
3239

3340
* - Parameter
34-
3541
- Type
36-
3742
- Description
38-
43+
3944
* - ``milliseconds``
40-
4145
- integer
42-
4346
- Specifies a cumulative time limit in milliseconds for processing operations
4447
on the cursor.
45-
46-
47-
48-
4948

5049
.. important::
5150

@@ -55,6 +54,12 @@ Definition
5554
to idle time. A cursor's idle time does not contribute towards its
5655
processing time.
5756

57+
The :method:`~cursor.maxAwaitTimeMS()` method sets a limit on how
58+
long a :ref:`tailable cursor <tailable-cursors-landing-page>` waits
59+
for the next response. It does not set a limit on total processing
60+
time.
61+
62+
5863
Behaviors
5964
---------
6065

@@ -140,3 +145,4 @@ Examples
140145
.. code-block:: javascript
141146

142147
db.collection.find({description: /August [0-9]+, 1969/}).maxTimeMS(50)
148+

source/reference/method/js-cursor.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ These methods modify the way that the underlying query is executed.
7575
* - :method:`cursor.max()`
7676
- Specifies an exclusive upper index bound for a cursor. For use
7777
with :method:`cursor.hint()`
78+
* - :method:`cursor.maxAwaitTimeMS()`
79+
- Specifies a limit in milliseconds to wait for the next query
80+
result update.
7881
* - :method:`cursor.maxTimeMS()`
7982
- Specifies a cumulative time limit in milliseconds for processing
8083
operations on a cursor.
@@ -141,6 +144,7 @@ These methods modify the way that the underlying query is executed.
141144
/reference/method/cursor.limit
142145
/reference/method/cursor.map
143146
/reference/method/cursor.max
147+
/reference/method/cursor.maxAwaitTimeMS
144148
/reference/method/cursor.maxTimeMS
145149
/reference/method/cursor.min
146150
/reference/method/cursor.next

0 commit comments

Comments
 (0)