Skip to content

Instantly share code, notes, and snippets.

@dpick
Created May 16, 2012 01:39
Show Gist options
  • Save dpick/2706625 to your computer and use it in GitHub Desktop.
Save dpick/2706625 to your computer and use it in GitHub Desktop.
class Redis
module Connection
class Logging < Redis::Connection::Ruby
def initialize(*args)
@command_queue = []
super
end
def write(*args)
@command_queue << [args, Time.now]
super
end
def read(*args)
command = @command_queue.shift
puts "Read command #{command.first.inspect}, it took #{Time.now - command.last}"
super
end
end
end
end
Redis::Connection.drivers << Redis::Connection::Logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment