Ana*_*and 2 ruby ruby-on-rails ruby-on-rails-3
我使用Rails 3.0.5和Ruby 1.9.2作为应用程序.在我的开发模式中,我已将缓存配置为ON.
config.action_controller.perform_caching = true
config.cache_store = :file_store, "#{Rails.root.to_s}/tmp/cache"
Run Code Online (Sandbox Code Playgroud)
在其中一个动作中,我有这行代码,
@featured_players = Rails.cache.fetch("featured-players") { Player.featured(8) }
Run Code Online (Sandbox Code Playgroud)
上面的行返回以下错误
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'
Run Code Online (Sandbox Code Playgroud)
featured
是一个Player模型的类方法,它通过db查询返回一个玩家数组.它只是一个普通的旧阵列.
什么似乎是错误..我已经尝试了几种方法来分析这个,但没有一个工作.请帮忙
缓存使用标准编组来缓存对象.您尝试序列化的其中一个对象中包含一个Mutex,但是您无法序列化只是运行时状态的东西:
无法转储某些对象:如果要转储的对象包括绑定,过程或方法对象,类IO实例或单例对象,则会引发TypeError.
问题是某些东西只作为运行时信息存在,并且无法自动重新创建.
你的播放器中某处有一个线程互斥,而且Marshal无法自动序列化互斥锁.你将不得不实现自己的序列化; Marshal文档中概述了两种执行此操作的方法:
marshal_dump
和marshal_load
方法._dump
和_load
方法.你可能想marshal_dump
和marshal_load
他们一起去,因为他们是最容易的.
归档时间: |
|
查看次数: |
3669 次 |
最近记录: |