Created
November 23, 2012 22:14
-
-
Save bradediger/4137531 to your computer and use it in GitHub Desktop.
Redis cache hit ratio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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