Skip to content

Instantly share code, notes, and snippets.

@joechrysler
Created May 16, 2012 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joechrysler/2713676 to your computer and use it in GitHub Desktop.
Save joechrysler/2713676 to your computer and use it in GitHub Desktop.
Playing with redis migrations
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