【发布时间】:2015-08-10 10:07:57
【问题描述】:
我正在尝试在 Memcache 中缓存 Weatherman 的响应 (https://github.com/dlt/yahoo_weatherman) 以避免多次获取天气,我正在这样做:
weather = Rails.cache.fetch([:weather_by_woeid, weather.woeid], expires_in: 1.hour) do
client = Weatherman::Client.new
client.lookup_by_woeid weather.woeid
end
但是我得到了这个异常:
ERROR -- : Marshalling error for key 'Timeline:weather_by_woeid/26352062': no _dump_data is defined for class Nokogiri::XML::NodeSet
ERROR -- : You are trying to cache a Ruby object which cannot be serialized to memcached.
ERROR -- : /var/lib/gems/2.2.0/gems/dalli-2.7.4/lib/dalli/server.rb:402:in `dump'
处理这个问题的最佳方法是什么?
【问题讨论】:
标签: ruby-on-rails ruby memcached nokogiri dalli