Class: RedisDashboard::Client
- Inherits:
-
Object
- Object
- RedisDashboard::Client
- Defined in:
- lib/redis_dashboard/client.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #clients ⇒ Object
- #close ⇒ Object
- #config ⇒ Object
- #info ⇒ Object
-
#initialize(url) ⇒ Client
constructor
A new instance of Client.
-
#slow_commands(length = 128) ⇒ Object
128 is the default slowlog-max-len.
Constructor Details
#initialize(url) ⇒ Client
4 5 6 |
# File 'lib/redis_dashboard/client.rb', line 4 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/redis_dashboard/client.rb', line 2 def url @url end |
Instance Method Details
#clients ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/redis_dashboard/client.rb', line 8 def clients connection.client.call([:client, "list"]).split("\n").map do |line| line.split(" ").reduce({}) do |hash, str| pair = str.split("=") hash[pair[0]] = pair[1] hash end end end |
#close ⇒ Object
31 32 33 |
# File 'lib/redis_dashboard/client.rb', line 31 def close connection.close if connection end |
#config ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/redis_dashboard/client.rb', line 18 def config hash = {} array = connection.config("get", "*") while (pair = array.slice!(0, 2)).any? hash[pair.first] = pair.last end hash end |
#info ⇒ Object
27 28 29 |
# File 'lib/redis_dashboard/client.rb', line 27 def info connection.info end |
#slow_commands(length = 128) ⇒ Object
128 is the default slowlog-max-len
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/redis_dashboard/client.rb', line 35 def slow_commands(length = 128) # 128 is the default slowlog-max-len connection.slowlog("get", length).map do |entry| cmd = RedisDashboard::Command.new cmd.id = entry[0] cmd. = entry[1] cmd.microseconds = entry[2] cmd.command = entry[3] cmd end.sort{ |left, right| right.microseconds <=> left.microseconds } end |