Sha256: b2cbfbad6ad810dff6a71549de5808e98f24212154cdd10569c25142b8598afe

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

require 'connection_pool'
require 'redis/namespace'

module Sidekiq
  class RedisConnection
    def self.create(options={})
      url = options[:url] || ENV['REDISTOGO_URL'] || 'redis://localhost:6379/0'
      client = build_client(url, options[:namespace])
      return ConnectionPool.new(:timeout => 1, :size => 25) { client } unless options[:use_pool] == false
      client
    end

    def self.build_client(url, namespace)
      client = Redis.connect(:url => url)
      if namespace
        Redis::Namespace.new(namespace, :redis => client)
      else
        client
      end
    end
    private_class_method :build_client
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-0.6.0 lib/sidekiq/redis_connection.rb