nutcracker 0.4.1.18 → 0.4.1.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -139,15 +139,20 @@ module Nutcracker
139
139
  # Returns hash with information about a given Redis
140
140
  def redis_info url
141
141
  begin
142
- redis = Redis.connect(url: url)
143
- info = redis.info
144
- db_size = redis.dbsize
145
- max_memory = (@options[:max_memory] || redis.config(:get, 'maxmemory')['maxmemory']).to_i
146
- redis.quit
142
+ r = Redis.connect url: url
143
+ info = r.info.merge 'dbsize' => r.dbsize
147
144
  rescue Exception
148
145
  return {}
149
146
  end
150
147
 
148
+ begin
149
+ info['maxmemory'] = @options.fetch(:max_memory) { r.config(:get, 'maxmemory')['maxmemory'] }
150
+ rescue Exception
151
+ info['maxmemory'] = info['used_memory_rss']
152
+ end
153
+
154
+ r.quit
155
+
151
156
  {
152
157
  'connections' => info['connected_clients'].to_i,
153
158
  'used_memory' => info['used_memory'].to_f,
@@ -157,8 +162,8 @@ module Nutcracker
157
162
  'evicted_keys' => info['evicted_keys'].to_i,
158
163
  'hits' => info['keyspace_hits'].to_i,
159
164
  'misses' => info['keyspace_misses'].to_i,
160
- 'keys' => db_size,
161
- 'max_memory' => max_memory,
165
+ 'keys' => info['dbsize'].to_i,
166
+ 'max_memory' => info['maxmemory'].to_i,
162
167
  'hit_ratio' => 0
163
168
  }.tap {|d| d['hit_ratio'] = d['hits'].to_f / (d['hits']+d['misses']).to_f if d['hits'] > 0 }
164
169
  end
@@ -1,3 +1,3 @@
1
1
  module Nutcracker
2
- VERSION = "0.4.1.18"
2
+ VERSION = "0.4.1.19"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutcracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1.18
4
+ version: 0.4.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eran Barak Levi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest