Class: RedisQueue::RedisConnection
- Inherits:
-
Object
- Object
- RedisQueue::RedisConnection
- Defined in:
- lib/redis_connection.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ RedisConnection
constructor
A new instance of RedisConnection.
- #new_redis ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ RedisConnection
Returns a new instance of RedisConnection.
4 5 6 |
# File 'lib/redis_connection.rb', line 4 def initialize(args) @args = args end |
Instance Method Details
#new_redis ⇒ Object
22 23 24 |
# File 'lib/redis_connection.rb', line 22 def new_redis ::Redis.new(@args) end |
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/redis_connection.rb', line 8 def run @redis ||= new_redis begin yield(@redis) rescue Redis::CannotConnectError, Redis::TimeoutError => e puts e.backtrace puts 'Redis crashed, retrying' sleep 2 @redis = new_redis retry end end |