开发者

Refresh ActiveResource Cache

I have an active reso开发者_开发百科urce model in one of my applications, and I need to be able occasionally do a find(:all), and force it to repull the data from the remote service. How can I do this? I saw the connection(refresh=true) piece, but I don't want it to refresh EVERY SINGLE TIME. More like I just want to be able to flush the cache when I want to, or to force a particular transaction to repull from the remote.


You might check out cached_resource. I am not sure how you are caching currently. Cached resource caches the responses to requests made with active resource. At the moment it seems to cache every request that goes through active resource, but allows you to refresh a specific request by doing:

MyActiveResource.all(:reload => true).


As far as I know, ActiveResource doesn't do any caching and will pull from the remote service every time you do find(:all).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜