Created
May 16, 2012 20:25
-
-
Save joechrysler/2713676 to your computer and use it in GitHub Desktop.
Playing with redis migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "redis" | |
origin = Redis.new(host: '127.0.0.1', port: 6379) | |
destination = Redis.new(host: '127.0.0.1', port: 6380) | |
500.times do |i| | |
origin.set(i, "value#{i}") | |
end | |
loop do | |
puts "Keys in origin: #{origin.keys("*").length}" | |
puts "Keys in destination: #{destination.keys("*").length}" | |
puts "Migrating..." | |
origin.keys("*").each do |key| | |
origin.migrate(destination[:host], destination[:port], key, 0, 1000) | |
end | |
puts "Keys in origin: #{origin.keys("*").length}" | |
puts "Keys in destination: #{destination.keys("*").length}" | |
puts "Migrating backwards..." | |
destination.keys("*").each do |key| | |
destination.migrate(origin[:host], origin[:port], key, 0, 1000) | |
end | |
puts | |
sleep 0.5 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment