【问题标题】:undefined method `cache_getter' for Typhoeus::HydraTyphoeus::Hydra 的未定义方法“cache_getter”
【发布时间】:2012-11-02 22:11:23
【问题描述】:

我不知道为什么会出现此错误。这两种方法都是正确的。

hydra = Typhoeus::Hydra.new

             hydra.cache_getter do |request|
                Rails.cache.read(request.cache_key) rescue nil
             end
             hydra.cache_setter do |request|
               Rails.cache.write(request.cache_key,request.response, expires_in: request.cache_timeout)
             end

ruby 1.9.2p320(2012-04-20 修订版 35421)[x86_64-darwin11.4.2]

Rails 3.2.8

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 typhoeus hydra


    【解决方案1】:

    您收到该错误是因为 Typhoeus::Hydra 实例上不存在这些方法。您可以在 http://rubydoc.info/gems/typhoeus/0.5.0/frames

    找到可用方法的完整列表

    更新

    通过this commit0.4.2 and 0.5.0 版本之间删除了这些方法

    【讨论】:

    • 好的,谢谢,Typhoeus 现在没有缓存系统了吗?
    • 好问题,我还没有在 Typhoeus 中对缓存做过任何事情。我建议联系作者,看看发生了什么。不幸的是,提交消息很糟糕:(
    • typhoeus 内置了缓存设施。当我正确理解它时,他们只是更改了 getter 和 setter 方法的接口并将其包装在一个类中。见:github.com/typhoeus/typhoeus#caching
    猜你喜欢
    • 2012-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-17
    • 2013-06-11
    • 2010-12-30
    相关资源
    最近更新 更多