Skip to content

Instantly share code, notes, and snippets.

@benaskins
Created July 2, 2009 23:45
Show Gist options
  • Save benaskins/139804 to your computer and use it in GitHub Desktop.
Save benaskins/139804 to your computer and use it in GitHub Desktop.
desc "Pre-fetch data from the webservice to avoid calling in line"
task :prefetch => [:environment, :preload_resources] do
UserLocality.all.collect { |ul| ul.locality }.uniq.each do |locality|
Rails.cache.fetch("location:#{locality.wz_location_code}", :expires_in => 10.minutes) do
locality.weather_location
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment