Rails: Scheduled task to warm up the cache?

前端 未结 4 797
暗喜
暗喜 2021-02-06 08:08

I am using the following to cache a slow loading page using memcached:

caches_action :complex_report, :expires_in => 1.day

The controller ac

4条回答
  •  隐瞒了意图╮
    2021-02-06 08:53

    If it's the process of running the report and collecting results that is time-consuming, you could cache those results (in place of, or along-side action caching) using Rails.cache.write and Rails.cache.read.

    Then, because you needn't worry about authentication or making requests to the server, the act of running the query and caching the results from a cron job would be considerably simpler.

提交回复
热议问题