Skip to content

Instantly share code, notes, and snippets.

@pixyj
pixyj / list_memcached_keys.sh
Last active March 2, 2016 06:53 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
require 'net/telnet'
require 'terminal-table'
# This code is copied from a comment on the original repo.
tbl = Terminal::Table.new headings: %w(id expires cache_key bytes)
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
matches = localhost.cmd("String" => "stats items", "Match" => /^END/).scan(/STAT items:(\d+):number (\d+)/)