【发布时间】:2011-05-08 09:05:37
【问题描述】:
我在使用 memcached 时遇到问题。
我在这里使用 Gregg Pollack 的示例http://railslab.newrelic.com/2009/02/19/episode-8-memcached
post.rb
def self.recent
Rails.cache.fetch('recent_posts', :expires_in => 15.minutes) do
self.order('id DESC').limit(15)
end
end
在我的控制器中,我使用@posts = Post.recent 调用它,并将其写入缓存。如果我重新加载页面,我会收到错误 TypeError: can't modify frozen object。
我在控制台中尝试了同样的事情,但我得到了同样的错误。我第一次执行@posts = Post.recent 时,键recent_posts 被添加到缓存中。当我第二次执行相同的命令时,我得到了冻结错误。
我正在使用 Rails 3.0.1 并在开发模式下工作。
我在这里做错了吗?
谢谢!
提姆
【问题讨论】:
标签: ruby-on-rails caching ruby-on-rails-3 memcached