Skip to content

Instantly share code, notes, and snippets.

@bradediger
Created November 23, 2012 22:14
Show Gist options
  • Save bradediger/4137531 to your computer and use it in GitHub Desktop.
Save bradediger/4137531 to your computer and use it in GitHub Desktop.
Redis cache hit ratio
#!/usr/bin/env ruby
hits_ = nil
misses_ = nil
loop do
`redis-cli info | grep keyspace` =~ /hits:(\d+).*misses:(\d+)/m
hits, misses = $1.to_i, $2.to_i
if hits_
dhits = hits - hits_
dmisses = misses - misses_
puts "%d: %.02f%% (%d / %d)" % [Time.now.to_i, dhits * 100.0 / (dhits + dmisses),
dhits, dhits + dmisses]
end
hits_ = hits
misses_ = misses
sleep 10
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment