开发者

ActiveRecord, Sinatra and Query Cache on Heroku

I have a rake task that I run to query my DB on heroku. My initialization for the task use setting Query Cache but I am not seeing any queries cached.

开发者_运维知识库
def init(args)
  ActiveRecord::Base.logger = Logger.new($stdout)
  ActiveRecord::Base.establish_connection(config[args[:environment]])
  use ActiveRecord::QueryCache
end 

def sometask(args)
  init(args)
  @foo.each do |f|
     x = f.something.find_by_foo_id(foo_id)
  end
end

Turns out when I examine the output I see repeatedly: SELECT * FROM foo WHERE foo_id = 1 or whatever. No caching is going on.

How do I force my code to use a cached query with ActiveRecord?


This gist should help you get what you want -- https://gist.github.com/712114

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜