redis_scanner 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4d4379646a6674439ca7ad275828c5881c97901
4
- data.tar.gz: 36e42b13cab65c468e71dded6a2edfafeaba3671
3
+ metadata.gz: 1f3caec0caf363f654534e72a721a6aa800db43e
4
+ data.tar.gz: fddaf355144726462164b00552c20be7fd4a5b79
5
5
  SHA512:
6
- metadata.gz: 1d4180f672190a047a5a39269b1d726ad8b26c3dfe9d640d8839006c0be2050d96a185bbbaf16c883f62cc05afa6387f00ba62de2c8c325aab542431c8cbc21e
7
- data.tar.gz: 83599028ff33ec24a5f573a5332aedb1db25a03c9a7e3daebd364210cffc34e52e6d39af65052a7ef0aaecbc5cf90ff0df278b8d5ad27b1acc5d5fb4a0193fd6
6
+ metadata.gz: c996fbbec218b7c45d69f838da6750f46c96c750419ee1a8b64d474b10a94709b246b9c179b49acbfc6164bd991d7cbc737bf75252f94b30534b6cf75be541ab
7
+ data.tar.gz: be62722d95943fbdd710ba533a3f9d940df39b3260b0b48591f30da7dc0fd6189ef8fccf4646e615997980efed397e760720a14e49748b0e65bb0b5bdf876c55
data/README.md CHANGED
@@ -46,26 +46,26 @@ The Output is like this:
46
46
  ```
47
47
 
48
48
  ```shell
49
- redis_scanner -d
49
+ redis_scanner -d -l 10
50
50
  ```
51
51
 
52
52
  The Output is like this:
53
53
 
54
54
  ```shell
55
- +------------------------------------+-------+--------+---------+
56
- | Key | Count | Size | AvgSize |
57
- +------------------------------------+-------+--------+---------+
58
- | demo:user:<id>:counter | 10000 | | |
59
- | > string | 10000 | 927510 | 92.75 |
60
- | u:<uuid>:pf | 52 | | |
61
- | > hash | 52 | 108 | 2.08 |
62
- | sidekiq_demo:stat:failed:<date> | 4 | | |
63
- | > string | 4 | 5 | 1.25 |
64
- | sidekiq_demo:stat:processed:<date> | 4 | | |
65
- | > string | 4 | 6 | 1.5 |
66
- | _sp_one:queue:default | 1 | | |
67
- | > list | 1 | 1 | 1.0 |
68
- +------------------------------------+-------+--------+---------+
55
+ +------------------------------------+--------+-------+--------+---------+
56
+ | Key | Type | Count | Size | AvgSize |
57
+ +------------------------------------+--------+-------+--------+---------+
58
+ | demo:user:<id>:counter | string | 10000 | 927510 | 92.75 |
59
+ | u:<uuid>:pf | hash | 52 | 108 | 2.08 |
60
+ | sidekiq_demo:stat:failed:<date> | string | 4 | 5 | 1.25 |
61
+ | sidekiq_demo:stat:processed:<date> | string | 4 | 6 | 1.5 |
62
+ | _sp_one:queue:default | list | 1 | 1 | 1.0 |
63
+ | bh:queues | set | 1 | 1 | 1.0 |
64
+ | bh:retry | zset | 1 | 1 | 1.0 |
65
+ | bh:stat:failed | string | 1 | 1 | 1.0 |
66
+ | bh:stat:processed | string | 1 | 1 | 1.0 |
67
+ | bus_app:app_two | hash | 1 | 1 | 1.0 |
68
+ +------------------------------------+--------+-------+--------+---------+
69
69
  ```
70
70
 
71
71
  * Scan keys with some pattern
data/bin/redis_scanner CHANGED
@@ -27,7 +27,7 @@ OptionParser.new do |opts|
27
27
  end
28
28
 
29
29
  options[:format] = 'table'
30
- opts.on("-t FORMAT", "--format FORMAT", "Formt(simple or talbe. default is table)") do |v|
30
+ opts.on("-t FORMAT", "--format FORMAT", "Format(simple or talbe. default is table)") do |v|
31
31
  options[:format] = v
32
32
  end
33
33
 
@@ -46,12 +46,12 @@ module RedisScanner
46
46
  else
47
47
  stat[pattern].increment
48
48
  end
49
- bar.increment
49
+ bar.increment unless bar.finished?
50
50
  end
51
51
  cursor = cursor.to_i
52
52
  break if cursor == 0
53
53
  end
54
- bar.finish
54
+ bar.finish unless bar.finished?
55
55
 
56
56
  stat
57
57
  end
@@ -41,9 +41,8 @@ module RedisScanner
41
41
 
42
42
  patterns.each do |pattern|
43
43
  if with_detail
44
- rows << [pattern.name, pattern.total, "", ""]
45
44
  pattern.sorted_items.each do |item|
46
- rows << [" > #{item.type}", item.count, item.size, item.avg_size]
45
+ rows << [pattern.name, item.type, item.count, item.size, item.avg_size]
47
46
  end
48
47
  else
49
48
  rows << [pattern.name, pattern.total]
@@ -52,17 +51,19 @@ module RedisScanner
52
51
  break if touch_limit?(count)
53
52
  end
54
53
 
55
- headings = ['Key', 'Count']
54
+
56
55
  if with_detail
57
- headings << "Size"
58
- headings << "AvgSize"
56
+ headings = %w(Key Type Count Size AvgSize)
57
+ else
58
+ headings = %w(Key Count)
59
59
  end
60
60
 
61
61
  table = Terminal::Table.new headings: headings, rows: rows
62
- table.align_column(1, :right)
62
+
63
63
  if with_detail
64
- table.align_column(2, :right)
65
- table.align_column(3, :right)
64
+ 4.times {|i| table.align_column(i+2, :right) }
65
+ else
66
+ table.align_column(1, :right)
66
67
  end
67
68
 
68
69
  table.to_s
@@ -60,11 +60,12 @@ module RedisScanner
60
60
  end
61
61
 
62
62
  def to_s
63
- ret = "#{name} #{total}"
64
63
  if @items.size > 0
65
- sorted_items.each do |item|
66
- ret << "\n #{item}"
67
- end
64
+ ret = sorted_items.map do |item|
65
+ "#{@name} #{item}"
66
+ end.join("\n")
67
+ else
68
+ ret = "#{@name} #{@total}"
68
69
  end
69
70
  ret
70
71
  end
@@ -1,3 +1,3 @@
1
1
  module RedisScanner
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Xie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis