开发者

How to store a database intensive page into cache from a background process in rails [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 2 years ago.

Improve this question

In my website i have a database intensive page which i cache for 5 mins. But still the performance is hit when the cache expires and the page has to be render开发者_如何学Goed freshly. I was thinking why not compute the page from a background process(like workling) once in 5 mins and store it in the cache and let the user request be serve from the cache everytime. And as a result no user have to wait for this page to be rendered.

Is there a efficient way to do it? Any help very much appreciated.

Thanks,


I would recommend simply making a call to your web-server for the page from your background-job or cron job. Then you let your entire Rails stack handle the call. You could create a cron job to do this every 4-5 minutes and pass a parameter to the page to have it force a cache refresh, for example:

complex/page?force=true

Your controller/action/model would then check for the presence of this parameter. If force was present the page would not use the cached version, but would re-create the cache instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜