Method: Xunch::RedisClient#initialize

Defined in:
lib/xunch/shard/redis.rb

#initialize(options = {}) ⇒ RedisClient

Returns a new instance of RedisClient.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/xunch/shard/redis.rb', line 14

def initialize(options = {})
  options = DEFAULTS.merge(options)
  if RUBY_PLATFORM =~ /mingw/
    options[:driver] = nil
  end
  if(options[:pool_timeout] <= 0)
    options[:pool_timeout] = 1073741823
  end
  last_driver = Redis::Connection.drivers.last.name
  options[:driver] ||= last_driver[last_driver.rindex(':') + 1, last_driver.length].downcase.to_sym
  if options[:driver] == :synchrony
      require "xunch/connection/fiber_redis_pool"
      @pool = FiberRedisPool.new(options)
  else
      require "xunch/connection/threaded_redis_pool"
      @pool = ThreadedRedisPool.new(options)
  end
end