Module: Protocol::Redis::Methods::Server

Defined in:
lib/protocol/redis/methods/server.rb

Overview

Methods for managing Redis servers.

Instance Method Summary collapse

Instance Method Details

#client_infoObject

Get the client information for the current connection. See <redis.io/commands/client-info> for more details.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/protocol/redis/methods/server.rb', line 32

def client_info
   = {}
  
  call("CLIENT", "INFO").split(/\s+/).each do |pair|
    key, value = pair.split("=")
    
    if value
      [key.to_sym] = value
    else
      [key.to_sym] = nil
    end
  end
  
  return 
end

#flushdb!Object

Remove all keys from the current database. See <redis.io/commands/flushdb> for more details.



51
52
53
# File 'lib/protocol/redis/methods/server.rb', line 51

def flushdb!
  call("FLUSHDB")
end

#infoObject

Get information and statistics about the server. See <redis.io/commands/info> for more details.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/protocol/redis/methods/server.rb', line 15

def info
   = {}
  
  call("INFO").each_line(Redis::Connection::CRLF) do |line|
    key, value = line.split(":")
    
    if value
      [key.to_sym] = value.chomp!
    end
  end
  
  return 
end