lib/redimap/redis_conn.rb in redimap-0.2.0 vs lib/redimap/redis_conn.rb in redimap-0.3.0

- old
+ new

@@ -8,12 +8,22 @@ @@RESCUE_QUEUE = 'redimap' @@RESCUE_CLASS = 'RedimapJob' def initialize - @redis = Redis.connect(:url => Redimap.config.redis_url) + @logger = Redimap.logger + begin + @redis = Redis.connect(:url => Redimap.config.redis_url) + + @redis.ping + rescue Redis::CannotConnectError => e + @logger.error { e.to_s } + + return + end + @KEYS = { :redimap_mailboxes => "#{Redimap.config.redis_ns_redimap}:mailboxes", :rescue_queues => "#{Redimap.config.redis_ns_queue}:queues", :rescue_queue_redimap => "#{Redimap.config.redis_ns_queue}:queue:#{@@RESCUE_QUEUE}", }.freeze @@ -24,12 +34,10 @@ close end end def close - if @redis - @redis.quit - end + @redis.quit end def get_mailbox_uid(mailbox) @redis.hget(@KEYS[:redimap_mailboxes], mailbox).to_i # Also handles nil. end