Module: Memcached
- Defined in:
- lib/em-synchrony/em-remcached.rb
Class Method Summary collapse
Class Method Details
.connect(servers) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/em-synchrony/em-remcached.rb', line 10 def connect(servers) Memcached.servers = servers f = Fiber.current @w = EM::Timer.new(10.0) { f.resume :error } @t = EM::PeriodicTimer.new(0.01) do if Memcached.usable? @w.cancel @t.cancel f.resume(self) end end r = Fiber.yield (r == :error) ? (raise Exception.new('Cannot connect to memcached server')) : r end |