Skip to content

Instantly share code, notes, and snippets.

@lucasuyezu
Created February 2, 2015 05:50
Show Gist options
  • Save lucasuyezu/51ac0f18c9c2a6b33217 to your computer and use it in GitHub Desktop.
Save lucasuyezu/51ac0f18c9c2a6b33217 to your computer and use it in GitHub Desktop.
puts "1) Fetching data"
http = EventMachine::HttpRequest.new("https://api.bitcoinaverage.com/ticker/global/all").get
http.errback { p '3) Not-done! Error!'; EM.stop }
http.callback do
# 1 second later
$redis.set(response_body["data"])
puts "3) Storing fetched data"
p http.response_header.status
p http.response_header
p http.response
puts "4) Done!"
EventMachine.stop
end
puts "2) Doing other things"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment