mongoid query caching

后端 未结 4 1838
忘掉有多难
忘掉有多难 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:59

    Mongoid has caching, described under http://mongoid.org/en/mongoid/docs/extras.html

    Also MongoDB itself has caching ability: http://www.mongodb.org/display/DOCS/Caching

    The mongoid caching extra knows 2 different cases: Caching of all queries of a model or caching of a query.

    Mongoid caching seems to work slightly different: it looks like mongoid delegates caching to mongodb. (In the sources of mongoid I only can find option settings for caching but no cache module.)

    Finally would say, there is no real difference in the caching in general -- in memory is in fact in memory! No matter if it's in the app or in the database.

    I don't prefer to implement an extra caching algorithm, because this seems to be redundant and a RAM killer.

    BTW: If your really want to cache results in-app you could try Rails.cache or another cache gem as a workaround.

提交回复
热议问题