Skip to content

Instantly share code, notes, and snippets.

@benaskins
Forked from lachie/gist:390226
Created May 5, 2010 00:47
Show Gist options
  • Save benaskins/390232 to your computer and use it in GitHub Desktop.
Save benaskins/390232 to your computer and use it in GitHub Desktop.
task :cache => :environment do
hydra = Typhoeus::Hydra.hydra
Site.all.each do |site|
fork do
Locality.each_url(site.webservice_connection) do |url|
req = # build request
hydra.queue
end
end
end
hydra.on_complete do |response|
if response.success?
LocationCacher.cache(response.body) # can give you headers too if you need 'em
else
# panic! hoptoad etc.
end
end
hydra.run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment