Class: RedisFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/redis_factory.rb

Class Method Summary collapse

Class Method Details

.convert_to_redis_client_options(address_or_options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/redis/redis_factory.rb', line 15

def convert_to_redis_client_options(address_or_options)
  return address_or_options if address_or_options.is_a?(Hash)
  host, port = address_or_options.split /\:/
  port, db   = port.split /\// if port
  options = {}
  options[:host] = host if host
  options[:port] = port if port
  options[:db]  = db.to_i if db
  options
end

.create(*redis_client_options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/redis/redis_factory.rb', line 3

def create(*redis_client_options)
  redis_client_options = redis_client_options.flatten.compact.inject([]) do |result, address|
    result << convert_to_redis_client_options(address)
    result
  end
  if redis_client_options.size > 1
    DistributedMarshaledRedis.new redis_client_options
  else
    MarshaledRedis.new redis_client_options.first || {}
  end
end