godredis 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -46
  3. data/godredis.gemspec +3 -1
  4. data/lib/godredis.rb +8 -4
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 997523d959196b0d1f84f05ca4d2a1658aa97f46
4
- data.tar.gz: 6ff84c78859b12c8a9f1ad6c4528c761fcf8de15
3
+ metadata.gz: 7b39e42f40ee4cbdef7f3a8c3521410c0adb8836
4
+ data.tar.gz: ed9788dd87ad5ca1a911fa1abe226c6bd5e80452
5
5
  SHA512:
6
- metadata.gz: 1c8194aace19d508f635cc8b2e6be57815a09f182c301a835aa1ed2bc956a4c14e0aeedf79af899223fc6abb4c43562631d4f8c300155481ee65ae01798bfcee
7
- data.tar.gz: 999b140c98f51e8f81c9b3a4b1ca47dd5a12564bd062a14abf6e44ed4c14d3dd7930aba6a5281edc4e811d8d8b9358d80709c7efafee66651d38f79041741e90
6
+ metadata.gz: 7d616cd1a688dbdf492b0cf8b2a6fa6fd13b232063fe5f6442f4b67504c0cb4bb4cf9efb8ecba08871bda247e2a3e98695f5790cedcd0a96174a5665ba135d03
7
+ data.tar.gz: 9079b30e860812f17c08caaae4237e1717d08c208e3a5bb3131f4b281f8929d21296b9a83c3b17b9e0286147dc4f34a3099ec67fa684d3312ca98facbe831f45
data/README.md CHANGED
@@ -4,12 +4,14 @@ Godredis gem provides unified interface for mass managing [Redis](http://redis.i
4
4
 
5
5
  It is useful when you need to close or reset connections on forking, for example, with [puma](http://github.com/puma/puma) server in the `on_restart` block:
6
6
 
7
- on_restart do
8
- # Rails.cache.instance_variable_get('@data').quit
9
- # Redis::Objects.redis.quit
10
- # Sidekiq.redis(&:quit)
11
- Godredis.quit_all! # instead of commented lines above
12
- end
7
+ ````ruby
8
+ on_restart do
9
+ # Rails.cache.instance_variable_get('@data').quit
10
+ # Redis::Objects.redis.quit
11
+ # Sidekiq.redis(&:quit)
12
+ Godredis.quit_all! # instead of commented lines above
13
+ end
14
+ ````
13
15
 
14
16
  ## Installation
15
17
 
@@ -29,60 +31,68 @@ Or install it yourself as:
29
31
 
30
32
  There are several ways to call bulk commands with Godredis:
31
33
 
32
- # Godredis.command_all! -- will output command execution result
33
- Godredis.reconnect_all! # => Redis [cache_store]: reconnect... [OK]
34
- # => Redis [objects]: reconnect... [OK]
35
- # => Redis [sidekiq]: reconnect... [OK]
36
-
37
- # Godredis.command_all -- silent
38
- Godredis.quit_all
39
-
40
- # Just different syntax
41
- Godredis.redises(&:quit)
42
- Godredis.redises(&:quit!)
43
-
44
- # It's also return an enumerator, so you can do something like this:
45
- Godredis.redises.map(&:connected?)
34
+ ````ruby
35
+ # Godredis.command_all! -- will output command execution result
36
+ Godredis.reconnect_all! # => Redis [cache_store]: reconnect... [OK]
37
+ # => Redis [objects]: reconnect... [OK]
38
+ # => Redis [sidekiq]: reconnect... [OK]
39
+
40
+ # Godredis.command_all -- silent
41
+ Godredis.quit_all
42
+
43
+ # Just different syntax
44
+ Godredis.redises(&:quit)
45
+ Godredis.redises(&:quit!)
46
+
47
+ # It's also return an enumerator, so you can do something like this:
48
+ Godredis.redises.map(&:connected?)
49
+ ````
46
50
 
47
51
  Subclass `Godredis::Base` class to collect Redis-related objects and use simple DSL to set mapping for the common methods such as `quit` or `reconnect` if they are different from the defaults.
48
52
 
49
- class CacheStoreGodredis < Godredis::Base
50
- redis ->{ Rails.cache.instance_variable_get('@data') }
51
- end
52
-
53
- class ObjectsGodredis < Godredis::Base
54
- redis ->{ Redis::Objects.redis }
55
- end
56
-
57
- class SidekiqGodredis < Godredis::Base
58
- # define mappings with blocks or lambdas
59
- redis ->(&block){ Sidekiq.redis &block }
60
- client { redis &:client }
61
- quit { redis &:quit }
62
- end
53
+ ````ruby
54
+ class CacheStoreGodredis < Godredis::Base
55
+ redis ->{ Rails.cache.instance_variable_get('@data') }
56
+ end
57
+
58
+ class ObjectsGodredis < Godredis::Base
59
+ redis ->{ Redis::Objects.redis }
60
+ end
61
+
62
+ class SidekiqGodredis < Godredis::Base
63
+ # define mappings with blocks or lambdas
64
+ redis ->(&block){ Sidekiq.redis &block }
65
+ client { redis &:client }
66
+ quit { redis &:quit }
67
+ end
68
+ ````
63
69
 
64
70
  Default mapping:
65
71
 
66
- redis { Redis.current }
67
- client { redis.client }
68
- connected? { client.connected? }
69
- reconnect { client.reconnect.connected? }
70
- quit { redis.quit }
72
+ ````ruby
73
+ redis { Redis.current }
74
+ client { redis.client }
75
+ connected? { client.connected? }
76
+ reconnect { client.reconnect.connected? }
77
+ quit { redis.quit }
78
+ ````
71
79
 
72
80
  You may also add custom commands:
73
81
 
74
- class SomeGodredis < Godredis::Base
75
- del_some_key { redis.del('some_key') }
76
- end
77
-
78
- Godredis.redises(&:del_some_key!)
79
- # etc...
82
+ ````ruby
83
+ class SomeGodredis < Godredis::Base
84
+ del_some_key { redis.del('some_key') }
85
+ end
86
+
87
+ Godredis.redises(&:del_some_key!)
88
+ # etc...
89
+ ````
80
90
 
81
91
  Every commands (except question-marked) also has a banged wrapper `command!`, which calls an itself command and puts a short message about its execution result.
82
92
 
83
93
  ## Contributing
84
94
 
85
- 1. Fork it ( https://github.com/[my-github-username]/godredis/fork )
95
+ 1. Fork it ( https://github.com/estum/godredis/fork )
86
96
  2. Create your feature branch (`git checkout -b my-new-feature`)
87
97
  3. Commit your changes (`git commit -am 'Add some feature'`)
88
98
  4. Push to the branch (`git push origin my-new-feature`)
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "godredis"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["Tõnis Simo"]
9
9
  spec.email = ["anton.estum@gmail.com"]
10
10
  spec.summary = %q{Godredis: bulk managing multiply Redis instances.}
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.required_ruby_version = ">= 1.9.3"
23
+
22
24
  spec.add_development_dependency "bundler", "~> 1.6"
23
25
  spec.add_development_dependency "rake"
24
26
  spec.add_dependency "activesupport", ">= 3.0.0"
@@ -121,13 +121,17 @@ module Godredis
121
121
 
122
122
  private
123
123
  def say(action, &block)
124
- result = _get_short_status_calling(&block)
124
+ result = get_short_status_calling(&block)
125
125
  puts "Redis [#{tag}]: #{action}... #{result}"
126
126
  end
127
127
 
128
- def _get_short_status_calling(&block)
129
- result = begin; block.call rescue nil; end
130
- result == true ? '[OK]' : result || '[FAIL]'
128
+ def get_short_status_calling(&block)
129
+ result = begin
130
+ block.call
131
+ rescue => e
132
+ "[FAIL] #{e.message}"
133
+ end
134
+ result == true ? '[OK]' : result || "[FAIL]"
131
135
  end
132
136
  end
133
137
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: godredis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tõnis Simo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: 1.9.3
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.2.2
91
+ rubygems_version: 2.4.3
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: 'Godredis: bulk managing multiply Redis instances.'