Skip to content

Commit 7334484

Browse files
author
Emily Giurleo
authored
RUBY-2413 Add a test and documentation for system collections with query cache (#2105)
1 parent 81ebaff commit 7334484

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

source/tutorials/query-cache.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,24 @@ The query cache also caches the results of aggregation pipelines. For example:
211211
Aggregation results are cleared from the cache during every write operation,
212212
with no exceptions.
213213

214+
System Collections
215+
==================
216+
217+
MongoDB stores system information in collections that use the ``database.system.*``
218+
namespace pattern.
219+
220+
When the query cache is enabled, it will cache all system collection results.
221+
However, system collections are not subject to the same cache invalidation rules
222+
as normal collections; if your app relies on up-to-date information from
223+
system collections, please ensure that you are performing queries against the
224+
system collections with the query cache disabled, as demonstrated below.
225+
226+
.. code-block:: ruby
227+
228+
Mongo::QueryCache.uncached do
229+
Mongo::Client.new([ '127.0.0.1:27017' ], database: 'admin') do |client|
230+
users = client['system.users'].find.to_a
231+
#=> Does not return cached results
232+
end
233+
end
234+

0 commit comments

Comments
 (0)