通过 Touch 进行片段缓存
目前我正在使用带有对象键的片段缓存。我使用 Touch 更新了 Updated_at 列来使缓存过期,然后当前的缓存就变得过时了。并且下次会生成新的缓存。
<% cache do product %>
对象的缓存键如下所示
table_name/ID-updated_at
现在我想将我的产品缓存在其他地方。为此,我想做与以前相同的事情,即简单地在缓存选项中提供对象,但我不能这样做:(
如果我可以生成这样的密钥以便仍然拥有我的缓存,那就太好了 不幸的是,
table_name/ID-something_updated_at
<% cache product,something do %>
这是不可能的,有人知道我如何解决我的问题吗
?
Currently I am using fragment caching with an object key. And I expire the cache using Touch with updates the updated_at column and then the current cache become obsolete. And a new cache is generated the next time.
<% cache do product %>
The cache key for an object looks like this
table_name/ID-updated_at
Now I want to cache my products somewhere else. To do so I would like to do same thing as before which is simply give the object in cache options, but I can't do that :(
It would be great if I could generate a key like this in order to still have my cache expired with the Touch.
table_name/ID-something_updated_at
<% cache product,something do %>
Unfortunately this is not possible, does someone has any idea how I could solve my problem?
Greg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将任何您喜欢的旧数组传递给片段,因此这是一个非常简单的更改来实现您所追求的目标:
You can pass any old array you like to the fragment, so it's a pretty simple change to achieve what you're after: