From: antirez Date: Tue, 21 Apr 2009 23:44:48 +0000 (+0200) Subject: FLUSHALL/FLUSHDB no longer sync on disk. Just increment the dirty counter by the... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/ca37e9cde814dd093cf2cf5d36f178854d768b3e FLUSHALL/FLUSHDB no longer sync on disk. Just increment the dirty counter by the number of elements removed, that will probably trigger a background saving operation --- diff --git a/redis.c b/redis.c index 7c382af7..e74910ba 100644 --- a/redis.c +++ b/redis.c @@ -875,13 +875,16 @@ static void initServer() { } /* Empty the whole database */ -static void emptyDb() { +static long long emptyDb() { int j; + long long removed = 0; for (j = 0; j < server.dbnum; j++) { + removed += dictSize(server.db[j].dict); dictEmpty(server.db[j].dict); dictEmpty(server.db[j].expires); } + return removed; } /* I agree, this is a very rudimental way to load a configuration... @@ -3038,18 +3041,17 @@ static void sunionstoreCommand(redisClient *c) { } static void flushdbCommand(redisClient *c) { + server.dirty += dictSize(c->db->dict); dictEmpty(c->db->dict); dictEmpty(c->db->expires); - server.dirty++; addReply(c,shared.ok); - rdbSave(server.dbfilename); } static void flushallCommand(redisClient *c) { - emptyDb(); - server.dirty++; + server.dirty += emptyDb(); addReply(c,shared.ok); rdbSave(server.dbfilename); + server.dirty++; } redisSortOperation *createSortOperation(int type, robj *pattern) {