Skip to content

@fcoury /gist:547851 forked from bryanl/gist:547726
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Memcache contents
require 'rubygems'
require 'net/telnet'
require 'memcache'
require 'action_view'
include ActionView::Helpers::TextHelper
cache = MemCache.new 'localhost:11211'
raw = Net::Telnet.new("Host" => "localhost", "Port" => 11211, "Prompt" => /END/)
items = raw.cmd("stats items")
keys = items.split(/\n/).
grep(/items:\w+:number/).
map{|x| x.match(/items:(\w+):number/)[1]}.
map{|x| raw.cmd("stats cachedump #{x} 100")}.
map{|x| x.split(/\s+/)[1]}
max_key_length = 0
keys.each{|key| max_key_length = key.size if key.size > max_key_length }
keys.each do |key|
data = truncate(cache.get(key).to_s.gsub(/\r\n/,'\r\n'), :length => 50)
printf("%30s | %s\n", key, data)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.