Class: MemcacheDo
- Inherits:
-
Object
- Object
- MemcacheDo
- Defined in:
- lib/memcache_do.rb
Class Method Summary collapse
Class Method Details
.exec(command, hostname = "localhost", port = "11211") ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/memcache_do.rb', line 4 def self.exec(command, hostname="localhost", port="11211") begin data = '' sock = TCPSocket.new(hostname, port) sock.print("#{command}\r\n") sock.flush # memcached does not close the socket once it is done writing # the stats data. We need to read line by line until we detect # the END line and then stop/close on our side. stats = sock.gets while true data += stats break if stats.strip == 'END' stats = sock.gets end sock.close data rescue => e puts e end end |