Module: Raidis
- Extended by:
- Raidis, Availability
- Included in:
- Raidis
- Defined in:
- lib/raidis.rb,
lib/raidis/throttle.rb,
lib/raidis/availability.rb,
lib/raidis/configuration.rb,
lib/raidis/configuration.rb,
lib/raidis/redis_wrapper.rb
Defined Under Namespace
Modules: Availability Classes: Configuration, RedisWrapper, Throttle
Constant Summary collapse
- ConnectionError =
Class.new(RuntimeError)
Instance Method Summary collapse
- #config ⇒ Object
- #configure {|config| ... } ⇒ Object
-
#connected? ⇒ Boolean
Public: Updates the #available? flag by actually testing the Redis connection.
-
#reconnect! ⇒ Object
Public: Evokes a fresh lookup of the Redis server endpoint.
-
#redis ⇒ Object
Public: The singleton Redis connection object.
-
#redis! ⇒ Object
Public: Creates a brand-new failsafe-wrapped connection to Redis.
- #reset! ⇒ Object
Methods included from Availability
available!, available?, unavailable!
Instance Method Details
#config ⇒ Object
81 82 83 |
# File 'lib/raidis/configuration.rb', line 81 def config @config ||= Configuration.new end |
#configure {|config| ... } ⇒ Object
85 86 87 |
# File 'lib/raidis/configuration.rb', line 85 def configure(&block) yield config end |
#connected? ⇒ Boolean
Public: Updates the #available? flag by actually testing the Redis connection.
Returns true or false.
30 31 32 33 34 35 |
# File 'lib/raidis.rb', line 30 def connected? return unavailable! unless @redis @redis.setex(:raidis, 1, :rocks) && available! rescue Raidis::ConnectionError unavailable! end |
#reconnect! ⇒ Object
Public: Evokes a fresh lookup of the Redis server endpoint.
39 40 41 42 |
# File 'lib/raidis.rb', line 39 def reconnect! @redis = nil redis end |
#redis ⇒ Object
Public: The singleton Redis connection object.
Returns a RedisWrapper instance.
19 20 21 22 23 24 |
# File 'lib/raidis.rb', line 19 def redis return @redis if @redis @redis = redis! connected? @redis end |
#redis! ⇒ Object
Public: Creates a brand-new failsafe-wrapped connection to Redis. This is ONLY useful if you need to maintain your own ConnectionPool. See github.com/mperham/sidekiq/issues/794
48 49 50 |
# File 'lib/raidis.rb', line 48 def redis! RedisWrapper.new end |
#reset! ⇒ Object
89 90 91 92 |
# File 'lib/raidis/configuration.rb', line 89 def reset! config = nil reconnect! end |