【问题标题】:Automatically refresh Rails cache after expired过期后自动刷新 Rails 缓存
【发布时间】:2013-11-18 05:07:20
【问题描述】:

我在我的 Rails 应用程序中使用页面缓存,并将缓存设置为在 5 分钟内过期。

这是我的控制器代码:

class HomeController < ApplicationController
  include HomeHelper

  caches_action :index, :expires_in => 5.minutes

  def index
    require 'feedzirra'

    @instagram = Instagram.user_recent_media('337349513', {:count => 15})
    @facebook = Feedzirra::Feed.fetch_and_parse('http://www.facebook.com/feeds/page.php?format=atom10&id=110243044484')
  end
end

是否可以在不触发索引操作的情况下自动刷新缓存(过期后)?

【问题讨论】:

  • 您可以运行一个非常简单的 cron 作业,只需每 5 分钟点击一次索引操作即可为您实现这一目标。
  • 我也考虑过 cron 工作,但我正在寻找更好的方法。看来是不可能了。

标签: ruby-on-rails caching


【解决方案1】:

我决定使用http://www.uptimerobot.com/ 每 5 分钟访问一次我的页面。检查何时有停机时间也很有用。

【讨论】:

    猜你喜欢
    • 2013-02-10
    • 2014-08-03
    • 1970-01-01
    • 2019-07-05
    • 2014-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多