Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Migrate redis key/values by key match
require 'redis'
redisSrc = Redis.connect url: "redis://<src>:6379"
redisDest = Redis.connect url: "redis://<dest>:6379"
redisSrc.keys("*").each do |key|
begin
data = redisSrc.dump key
ttl = redisSrc.pttl key # milleseconds
redisDest.restore key, ttl, data
rescue => e
p key, e
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.