GlobalFetcher def self.read(url) return false if !self.allow? self.hint open(url).read end def self.hint Rails.cache.increment("global_fetcher_#{Time.now.strftime("%Y%m%d%H%M")}" , 1) end def self.count Rails.cache.read("global_fetcher_#{Time.now.strftime("%Y%m%d%H%M")}" ).to_i || 0 end def self.allow? self.count < 40 end end 每分钟 40 次请求 12年7月27⽇日星期五