Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 过期后自动刷新Rails缓存_Ruby On Rails_Caching - Fatal编程技术网

Ruby on rails 过期后自动刷新Rails缓存

Ruby on rails 过期后自动刷新Rails缓存,ruby-on-rails,caching,Ruby On Rails,Caching,我在Rails应用程序中使用页面缓存,我将缓存设置为在5分钟内过期 这是我的控制器代码: class HomeController < ApplicationController include HomeHelper caches_action :index, :expires_in => 5.minutes def index require 'feedzirra' @instagram = Instagram.user_recent_media(

我在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
class HomeController5.5分钟
def索引
需要“feedzirra”
@instagram=instagram.user_recent_media('337349513',{:count=>15})
@facebook=Feedzirra::Feed.fetch和http://www.facebook.com/feeds/page.php?format=atom10&id=110243044484')
结束
结束

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

我决定每5分钟访问一次我的页面。检查停机时间也很有用。

我决定每5分钟访问一次我的页面。检查停机时间也很有用。

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