views:

28

answers:

1

I created a Rails app hosted on Heroku with a Memcache plugin limited to 5 MB.

How can I know about Memcache status, free cache left, biggest cache chunk etc.? Can I access this within the app (an admin page for example)? Or using the Ruby console? Also, is there any graphical plugin for this?

+2  A: 

From http://barkingiguana.com/2009/03/04/memcache-statistics-from-the-command-line

require 'socket'

socket = TCPSocket.open('localhost', '11211')
socket.send("stats\r\n", 0)

statistics = []
loop do
  data = socket.recv(4096)
  if !data || data.length == 0
    break
  end
  statistics << data
  if statistics.join.split(/\n/)[-1] =~ /END/
    break
  end
end

puts statistics.join()
Wrikken