Rails - caching external HTTP calls

My Rails application has to make a huge amount of external HTTP calls. Sometimes redundant HTTP calls process the request. So, I am looking for a way to cache external HTTP calls. The path should use memory to store cached data. Please, help.

+4
source share
1 answer

It looks like you could just use Rails caching to accomplish this, although I haven't tested it.

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 

Read more about caching Rails http://guides.rubyonrails.org/caching_with_rails.html

+8
source

Source: https://habr.com/ru/post/1486261/


All Articles