rails 3缓存:命名路由的过期操作 [英] rails 3 caching: expire action for named route

查看:71
本文介绍了rails 3缓存:命名路由的过期操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的控制器具有此功能:

My controller has this:

caches_action :render_ticker_for_channel, :expires_in => 30.seconds

在我的路线文件中,我有以下内容:

In my routes file I have this:

match '/render_c_t/:channel_id' => 'render#render_ticker_for_channel', :as => :render_channel_ticker

在日志文件中,我看到以下内容:

In the log file I see this:

Write fragment views/mcr3.dev/render_c_t/63 (11.6ms)

我如何手动使它过期?我需要使用与渲染控制器不同的控制器来使它到期,但是即使在渲染控制器中,我也无法使其到期。正确的事情。

How do I expire this manually? I need to expire this from a different controller than the render controller, but even within the render controller I can't get it to expire the right thing.

如果我这样做了:

 expire_action(:controller => 'render', :action => 'render_ticker_for_channel', :id => c.id)

我看到:

Expire fragment views/mcr3.dev/render/render_ticker_for_channel/63 (3.2ms)

如果我这样做:

expire_action(:controller => 'render', :action => 'render_c_t', :id => c.id)

我看到了:

Expire fragment views/mcr3.dev/render/render_c_t/63 (3.2ms)

此:

expire_action("render_c_t/#{c.id}")

产生:

Expire fragment views/render_c_t/63 (3.5ms)

如何能够我让它过期与 caches_action产生的路径相同吗?!

How can I get it to expire the same path that 'caches_action' is producing?!

推荐答案

使用expire_fragment

expire_fragment %r{render_c_t/#{c.id}/}

这篇关于rails 3缓存:命名路由的过期操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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