Method: Redis::Commands::Server#info

Defined in:
lib/redis/commands/server.rb

#info(cmd = nil) ⇒ Hash<String, String>

Get information and statistics about the server.

Parameters:

  • cmd (String, Symbol) (defaults to: nil)

    e.g. "commandstats"

Returns:

  • (Hash<String, String>)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/redis/commands/server.rb', line 89

def info(cmd = nil)
  send_command([:info, cmd].compact) do |reply|
    if reply.is_a?(String)
      reply = HashifyInfo.call(reply)

      if cmd && cmd.to_s == "commandstats"
        # Extract nested hashes for INFO COMMANDSTATS
        reply = Hash[reply.map do |k, v|
          v = v.split(",").map { |e| e.split("=") }
          [k[/^cmdstat_(.*)$/, 1], Hash[v]]
        end]
      end
    end

    reply
  end
end