我對應用程序使用Rails 3.0.5和Ruby 1.9.2。在我的開發模式中,我配置了緩存開啓。Rails 3高速緩存轉儲錯誤
config.action_controller.perform_caching = true
config.cache_store = :file_store, "#{Rails.root.to_s}/tmp/cache"
而在動作中的一個,我有這行代碼,
@featured_players = Rails.cache.fetch("featured-players") { Player.featured(8) }
上面一行返回以下錯誤
TypeError (no marshal_dump is defined for class Mutex):
activesupport (3.0.5) lib/active_support/cache/file_store.rb:100:in `dump'
activesupport (3.0.5) lib/active_support/cache/file_store.rb:100:in `block in write_entry'
activesupport (3.0.5) lib/active_support/core_ext/file/atomic.rb:20:in `atomic_write'
activesupport (3.0.5) lib/active_support/cache/file_store.rb:100:in `write_entry'
activesupport (3.0.5) lib/active_support/cache/strategy/local_cache.rb:135:in `write_entry'
activesupport (3.0.5) lib/active_support/cache.rb:364:in `block in write'
activesupport (3.0.5) lib/active_support/cache.rb:519:in `instrument'
featured
是播放器模型的一個類的方法作爲數據庫查詢的結果返回一個玩家數組。它只是一個普通的舊數組。
什麼似乎是錯誤..我嘗試了幾種方法來分析這個,但沒有工作。請幫忙
感謝您的解釋。所以..我需要創建FeaturedPlayerCached類,並在其中寫入方法marshal_dump和marshal_load .. ?? – Anand 2011-04-22 08:35:49
但我傾倒的對象是一個玩家對象數組=>我只是傾銷一個非常易於清理的數組(如果這就是正確的話) – Anand 2011-04-22 08:43:48
您的Player對象內有一個Mutex。可能是父類,可能是其中一個屬性。你可以在你的Player類中放置'marshal_dump'和'marshal_load'方法。 – 2011-04-22 09:08:16