lib/mongo/collection/view/readable.rb in mongo-2.13.3 vs lib/mongo/collection/view/readable.rb in mongo-2.14.0.rc1

- old
+ new

@@ -43,11 +43,21 @@ # # @return [ Aggregation ] The aggregation object. # # @since 2.0.0 def aggregate(pipeline, options = {}) - Aggregation.new(self, pipeline, options) + aggregation = Aggregation.new(self, pipeline, options) + + # Because the $merge and $out pipeline stages write documents to the + # collection, it is necessary to clear the cache when they are performed. + # + # Opt to clear the entire cache rather than one namespace because + # the $out and $merge stages do not have to write to the same namespace + # on which the aggregation is performed. + QueryCache.clear if aggregation.write? + + aggregation end # Allows the server to write temporary data to disk while executing # a find operation. # @@ -88,10 +98,10 @@ # @note Specifying 1 or a negative number is analogous to setting a limit. # # @param [ Integer ] batch_size The size of each batch of results. # # @return [ Integer, View ] Either the batch_size value or a - # new +View+. + # new +View+. # # @since 2.0.0 def batch_size(batch_size = nil) configure(:batch_size, batch_size) end