Created
January 10, 2013 04:00
-
-
Save robraux/4499334 to your computer and use it in GitHub Desktop.
This file contains 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
local res | |
local mover | |
-- step 1: ensure the target database is flushed | |
redis.call('select', ARGV[1]) | |
redis.call('flushdb') | |
-- step 2: fetch keys to transfer from database 0, that is one and only master | |
redis.call('select', 0) | |
res = redis.call('keys', '*') | |
for key, value in pairs(res) | |
do | |
-- this select is imperative to make sure we don't start dumping from the target | |
redis.call('select', 0) | |
mover = redis.call('DUMP', value) | |
redis.call('select', ARGV[1]) | |
-- do not care about TTLs, we are not testing that | |
redis.call('RESTORE', value, 0, mover) | |
end | |
-- leave redis select as you found it, just in case | |
redis.call('select', ARGV[1]) | |
return 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment