Reputation: 731
I have an application that get all its data from a Redis database (DB1), which is updated every hour by an external process. During this update, all the data in Redis is replaced.
To avoid having any errors on the main application when updating, I thought about having the updater process write to a secondary Redis database (DB2) and after finishing, switch this database with the one that the application is using.
I didn't find a way to rename or copy a whole Redis database, so the only way I can think of is to erase all keys from DB1 and than use MOVE to save all new keys from DB2 in DB1.
Is there a better way to accomplish this?
Upvotes: 0
Views: 1257
Reputation: 17520
Why not simply have DB2 SLAVEOF DB1, poll it with INFO and checking for master_sync_in_progress: 0?
When you're about to perform your updates to DB1 then SLAVEOF NO ONE on DB2 (break the replication). Perform your updates on DB1 while clients access the static (old) data on DB2; then reslave when the updates are complete on DB1.
Upvotes: 1