Ash*_*sta 4 caching ruby-on-rails http
我的Rails应用程序必须进行大量的外部http调用.有时,冗余的http调用来处理请求.所以,我正在寻找一种缓存外部http调用的方法.应该使用内存来保存缓存数据的方式.请帮忙.
看起来你可以使用Rails缓存来完成这个,虽然我还没有真正测试过它.
results = Rails.cache.fetch(cache_key) do # You could use a unique URL as part of the cache key
# HTTP request
# Return results from processing the response
end
Run Code Online (Sandbox Code Playgroud)
有关Rails缓存的更多信息,请访问http://guides.rubyonrails.org/caching_with_rails.html
| 归档时间: |
|
| 查看次数: |
1348 次 |
| 最近记录: |