4
我們有一個頁面顯示了我們應用程序的頂級組。領先榜的計算是昂貴的,所以我們緩存了一個小時,結果如下:Rails.cache.fetch插入額外的值
@groupboard = Rails.cache.fetch("top_groups", :expires_in => 1.hour) do
Group.top_groups
end
緩存已被寫入後的第一時間這是給了一個錯誤。在控制檯打探我看到Group.top_groups返回項目數組,如下所示:
[#<Group id: 4, name: "IBP", rank: 6, users_count: 13, leader_id: 4662>, 3887]
當我看到從緩存中返回的結果,它看起來如下:
[#<Group id: 4, name: "IBP", rank: 6, users_count: 13, leader_id: 4662>, :@new_record_before_save], false, 3887]
有沒有人知道會導致@ new_record_before_save和'false'值被插入緩存中這個對象的所有條目中?
我們使用的達利,Memcached的1.4.9,3.2.4的Rails和Ruby 1.9.2
這是一個已知[Rails的錯誤(https://github.com/rails/rails/issues/8020)用怎樣的方式編組(元帥.load)現在由Rails處理。你能提供關於你模型的更多細節,或者嘗試其中列出的解決方案之一嗎? – vipulnsward