Module: Adocca::MemCache::Server::TimeoutSocket

Defined in:
lib/am_memcache.rb

Defined Under Namespace

Classes: TimeoutError

Instance Method Summary collapse

Instance Method Details

#timeout_gets(timeout) ⇒ Object



422
423
424
425
426
427
428
# File 'lib/am_memcache.rb', line 422

def timeout_gets(timeout)
  if IO.select([self], nil, nil, timeout)
    self.gets
  else
    raise TimeoutError, "Timeout reached for #{self}.timeout_gets(#{timeout})"
  end
end

#timeout_write(message, timeout) ⇒ Object



415
416
417
418
419
420
421
# File 'lib/am_memcache.rb', line 415

def timeout_write(message, timeout)
  if IO.select(nil, [self], nil, timeout)
    self.write(message)
  else
    raise TimeoutError, "Timeout reached for #{self}.timeout_write(#{message.inspect}, #{timeout})"
  end
end