Memcached 错过了 Rails 上使用 Dalli gem 的每次获取
所以我有这个基本操作,它通过 ajax 调用访问,并获取最受欢迎的帖子,将它们存储在缓存中,然后显示在用户视图中:
def trending
@trends = Rails.cache.fetch('trends', :expires_in=>1.hour) { Post.trends.all }
respond_to do |format|
format.js {render :layout=>false}
end
end
config/development.rb
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and enable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = true
config.cache_store = :dalli_store
现在的问题是我的情况是,每次获取缓存都会丢失。有什么想法可能是错的吗?
谢谢!
So I have this basic action, which is accessed by ajax call, and fetches the most popular post, stores them in the cache and then displays in the users view:
def trending
@trends = Rails.cache.fetch('trends', :expires_in=>1.hour) { Post.trends.all }
respond_to do |format|
format.js {render :layout=>false}
end
end
config/development.rb
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and enable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = true
config.cache_store = :dalli_store
Now the problem that I have is that on every fetch cache is missed. Any ideas what might be wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将以下变量更改为 true
config.cache_classes = true
change the following variable to true
config.cache_classes = true