mongoid query caching

后端 未结 4 1889
忘掉有多难
忘掉有多难 2020-12-28 18:38

Rails\' ActiveRecord has a feature called Query Caching (ActiveRecord::QueryCache) which saves the result of SQL query for the life-span of a request. While I\'m not very fa

4条回答
  •  伪装坚强ぢ
    2020-12-28 18:54

    Mongoid 4.0+ now has a QueryCaching module: http://www.rubydoc.info/github/mongoid/mongoid/Mongoid/QueryCache

    You can use it on finds by wrapping your lookups like so:

    QueryCache.cache { MyCollection.find("xyz") }
    

提交回复
热议问题