Sha256: fcbbe855ce35de30e28735d725d022478d62f05f17f618664f1c5633983c035a

Contents?: true

Size: 724 Bytes

Versions: 6

Compression:

Stored size: 724 Bytes

Contents

class RedisFactory
  class << self
    def create(*addresses)
      addresses = extract_addresses(addresses)
      if addresses.size > 1
        DistributedMarshaledRedis.new addresses
      else
        MarshaledRedis.new addresses.first || {}
      end
    end
    
    private
      def extract_addresses(addresses)
        addresses = addresses.flatten.compact
        addresses.inject([]) do |result, address|
          host, port = address.split /\:/
          port, db   = port.split /\// if port
          address = {}
          address[:host] = host if host
          address[:port] = port if port
          address[:db]  = db.to_i if db
          result << address
          result
        end
      end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
jodosha-redis-store-0.3.0 lib/redis/redis_factory.rb
jodosha-redis-store-0.3.5 lib/redis/redis_factory.rb
jodosha-redis-store-0.3.6 lib/redis/redis_factory.rb
dsander-redis-store-0.3.8 lib/redis/redis_factory.rb
redis-store-0.3.7 lib/redis/redis_factory.rb
redis-store-0.3.6 lib/redis/redis_factory.rb