Sha256: a68cb1aa0f7b7abbc40a2b7c2f1467c8674a716753a40c15af36f829fc34c496

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

require 'connection_pool'
require 'redis'
require 'redis/namespace'

module Sidekiq
  class RedisConnection
    def self.create(options={})
      url = options[:url] || ENV['REDISTOGO_URL'] || 'redis://localhost:6379/0'
      size = (options[:size] || Sidekiq.options[:concurrency] || 25)
      ConnectionPool.new(:timeout => 1, :size => size) do
        build_client(url, options[:namespace])
      end
    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.11.1 lib/sidekiq/redis_connection.rb