Sha256: 72112e02ebb1d8c114fc197a1c6e25a43eb6b4a53328e707c0d793755b12e19c

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

class Redis
  class NativeMigrator
    def initialize(old_hosts)
      Thread.current[:redis] = Redis::Distributed.new(old_hosts)
    end

    def redis
      Thread.current[:redis]
    end

    def migrate(node_options, keys, _)
      new_node_options = { host: node_options[:host],
                           port: node_options[:port],
                           db:   node_options[:db] }

      grouped_by_old_nodes = keys.group_by do |key|
        redis.node_for(key)
      end

      grouped_by_old_nodes.each do |old_node, node_keys|
        old_node.pipelined do
          node_keys.each { |key| old_node.migrate(key, new_node_options) }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_migrator-0.1.1 lib/redis_migrator/redis_native_migrator.rb