class Rubykiq::Connection

Public Class Methods

new(options = {}) click to toggle source

Initialize a new Connection object

@param options [Hash]

# File lib/rubykiq/connection.rb, line 13
def initialize(options = {})
  url = options.delete(:url) { determine_redis_provider }
  namespace = options.delete(:namespace)
  driver = options.delete(:driver)
  @redis_connection = initialize_conection(url, namespace, driver)
  @redis_client = @redis_connection.client
  @redis_connection
end

Private Instance Methods

determine_redis_provider() click to toggle source
# File lib/rubykiq/connection.rb, line 24
def determine_redis_provider
  # lets try and fallback to another redis url
  ENV['REDISTOGO_URL'] || ENV['REDIS_PROVIDER'] || ENV['REDIS_URL'] || 'redis://localhost:6379/0'
end
initialize_conection(url, namespace, driver) click to toggle source
# File lib/rubykiq/connection.rb, line 29
def initialize_conection(url, namespace, driver)
  client = ::Redis.new(url: url, driver: driver)
  ::Redis::Namespace.new(namespace, redis: client)
end