Class: Redis::NativeMigrator
- Inherits:
-
Object
- Object
- Redis::NativeMigrator
- Defined in:
- lib/redis_migrator/redis_native_migrator.rb
Instance Method Summary collapse
-
#initialize(old_hosts) ⇒ NativeMigrator
constructor
A new instance of NativeMigrator.
- #migrate(node_options, keys, _) ⇒ Object
- #redis ⇒ Object
Constructor Details
#initialize(old_hosts) ⇒ NativeMigrator
Returns a new instance of NativeMigrator.
3 4 5 |
# File 'lib/redis_migrator/redis_native_migrator.rb', line 3 def initialize(old_hosts) Thread.current[:redis] = Redis::Distributed.new(old_hosts) end |
Instance Method Details
#migrate(node_options, keys, _) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/redis_migrator/redis_native_migrator.rb', line 11 def migrate(, keys, _) = { host: [:host], port: [:port], db: [: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, ) } end end end |
#redis ⇒ Object
7 8 9 |
# File 'lib/redis_migrator/redis_native_migrator.rb', line 7 def redis Thread.current[:redis] end |