Sha256: e2dff876f5399e7e81b20dba758e3a504553d73655e7e86f902b9209226204a3

Contents?: true

Size: 411 Bytes

Versions: 2

Compression:

Stored size: 411 Bytes

Contents

class Redis
  module Helper
    def to_redis_proto(*cmd)
      cmd.inject("*#{cmd.length}\r\n") {|acc, arg|
        acc << "$#{arg.to_s.bytesize}\r\n#{arg}\r\n"
      }
    end

    def parse_redis_url(redis_url)
      node = URI(redis_url)
      path = node.path
      db = path[1..-1].to_i rescue 0

      {
        host: node.host,
        port: node.port || 6379,
        db:   db
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis_migrator-0.1.2 lib/redis_migrator/redis_helper.rb
redis_migrator-0.1.1 lib/redis_migrator/redis_helper.rb