1
我想与mongoid cahce一起工作。Mongoid缓存似乎没有工作
首先我不知道在哪里把我的标准,现在它坐在一个类变量(感觉错了地方)
class YearDates
include Mongoid::Document
@@yeardates_cache = YearDates.where(year: DateHelper.today.year).cache
def self.current_year
@@yeardates_cache.first
end
现在我希望只打蒙戈一次当我打电话YearDates .current_year
不过来,每次我打电话CURRENT_YEAR我在日志中看到:
MOPED: 127.0.0.1:27017 QUERY database=unit_test collection=year_dates selector={"$query"=>{"year"=>2013}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil
任何想法?