Commit ca37e9cd authored by antirez's avatar antirez
Browse files

FLUSHALL/FLUSHDB no longer sync on disk. Just increment the dirty counter by...

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
parent 975a5b6f
...@@ -875,13 +875,16 @@ static void initServer() { ...@@ -875,13 +875,16 @@ static void initServer() {
} }
/* Empty the whole database */ /* Empty the whole database */
static void emptyDb() { static long long emptyDb() {
int j; int j;
long long removed = 0;
for (j = 0; j < server.dbnum; j++) { for (j = 0; j < server.dbnum; j++) {
removed += dictSize(server.db[j].dict);
dictEmpty(server.db[j].dict); dictEmpty(server.db[j].dict);
dictEmpty(server.db[j].expires); dictEmpty(server.db[j].expires);
} }
return removed;
} }
/* I agree, this is a very rudimental way to load a configuration... /* I agree, this is a very rudimental way to load a configuration...
...@@ -3038,18 +3041,17 @@ static void sunionstoreCommand(redisClient *c) { ...@@ -3038,18 +3041,17 @@ static void sunionstoreCommand(redisClient *c) {
} }
static void flushdbCommand(redisClient *c) { static void flushdbCommand(redisClient *c) {
server.dirty += dictSize(c->db->dict);
dictEmpty(c->db->dict); dictEmpty(c->db->dict);
dictEmpty(c->db->expires); dictEmpty(c->db->expires);
server.dirty++;
addReply(c,shared.ok); addReply(c,shared.ok);
rdbSave(server.dbfilename);
} }
static void flushallCommand(redisClient *c) { static void flushallCommand(redisClient *c) {
emptyDb(); server.dirty += emptyDb();
server.dirty++;
addReply(c,shared.ok); addReply(c,shared.ok);
rdbSave(server.dbfilename); rdbSave(server.dbfilename);
server.dirty++;
} }
redisSortOperation *createSortOperation(int type, robj *pattern) { redisSortOperation *createSortOperation(int type, robj *pattern) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment