How can I force Redis to do a blocking save? I am using the Ruby Red开发者_StackOverflow中文版is gem, but I believe this question is not specific to that library. It seems like SAVE and a BGSAVE commands seem to flutter away doing stuff in the background, causing "-ERR background save in progress" errors on subsequent calls.
Hopefully this would be a boring, synchronous call that blocks all other Redis commands until the save over "dump.rdb" is finished. And hopefully this will not require actually shutting down the server, mucking around with "/etc/init.d/redis-server". Presumably I should be polling with the LASTSAVE command?
if you call SAVE but you get an error about a background save in progress, this means that there is also a BGSAVE in progress, becuase one of this is true:
1) Somebody called BGSAVE 2) Redis is configured to save from time to time (the default).
So your SAVE fails since there is already a save in progress. You can check if there is a background in progress, and when it is completed, checking the INFO output.
SAVE
is a synchronous save; BGSAVE
is the asynchronous one.
Why do you think SAVE
is running in the background?
Redis#save does just that. What version of Redis and redis gem are you using?
精彩评论