在Rails中手动清除片段缓存 [英] Manually Clear Fragment Cache in Rails

查看:77
本文介绍了在Rails中手动清除片段缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Memcached与Heroku一起用于Rails 3.1应用程序。我有一个错误,并且显示了错误的内容-缓存的参数不正确。

I'm using Memcached with Heroku for a Rails 3.1 app. I had a bug and the wrong things are showing - the parameters were incorrect for the cache.

我有这个:

<% cache("foo_header_cache_#{@user.id}") do %> 

我删除了片段缓存并将其推送到Heroku,然后坏数据消失了。

I removed the fragment caching and pushed to Heroku and the bad data went away.

然后我将其更改为:

<% cache("foo_header_cache_#{@foo.id}") do %> 

但是,当我更正参数时,从@user到@foo,旧的[不正确]被缓存了版本再次显示(而不是刷新正确的数据)。

However, when I corrected the parameters, from @user to @foo, the old [incorrect] cached version showed again (instead of refreshing with the correct data).

我如何手动使它过期,否则要摆脱显示的错误数据?

How can I manually expire this, or otherwise get rid of this bad data that is showing?

推荐答案

我最终进入Rails控制台并使用以下命令手动清除了整个缓存:

I ended up manually clearing the entire cache by going into the rails console and using the command:

Rails.cache.clear

这篇关于在Rails中手动清除片段缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆