Skip to content

Instantly share code, notes, and snippets.

@warrickcustomhomes
Created January 12, 2011 17:47
Show Gist options
  • Save warrickcustomhomes/776547 to your computer and use it in GitHub Desktop.
Save warrickcustomhomes/776547 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
EM.run do
memcache = EM::Protocols::Memcache.connect('127.0.0.1', 11211)
begin
memcache.get(:foo) do |value|
if value.nil?
raise Exception, "Tag :foo not found"
end
puts "Value Returned: #{value}"
EM.stop_event_loop
end
rescue Exception => ex
puts 'Failed to get tag...'
end
end
# scrapcoder:~$ ruby memcache-test.rb
# em-test.rb:10: Tag :foo not found (Exception)
# from /home/scrapcoder/.gems/gems/eventmachine-0.12.10/lib/em/protocols/memcache.rb:63
# from /home/scrapcoder/.gems/gems/eventmachine-0.12.10/lib/em/protocols/memcache.rb:183:in `call'
# from /home/scrapcoder/.gems/gems/eventmachine-0.12.10/lib/em/protocols/memcache.rb:183:in `process_cmd'
# from /home/scrapcoder/.gems/gems/eventmachine-0.12.10/lib/em/protocols/memcache.rb:157:in `receive_data'
# from /home/scrapcoder/.gems/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
# from /home/scrapcoder/.gems/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
# from em-test.rb:4
@warrickcustomhomes
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment