Ruby on rails 过期后自动刷新Rails缓存
我在Rails应用程序中使用页面缓存,我将缓存设置为在5分钟内过期 这是我的控制器代码: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(
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作业,但我正在寻找更好的方法。看来这是不可能的。