Return the set of flags to use for the emptyDb() call for FLUSHALL * and FLUSHDB commands. * * sync: flushes the database in an sync manner. * async: flushes the database in an async manner. * no option: determine sync or async according to the value of lazyfree-lazy-user-flush. * * On success C_OK is returned and the flags are stored in *flags, otherwise * C_ERR is returned and the functi
| 610 | * On success C_OK is returned and the flags are stored in *flags, otherwise |
| 611 | * C_ERR is returned and the function sends an error to the client. */ |
| 612 | int getFlushCommandFlags(client *c, int *flags) { |
| 613 | /* Parse the optional ASYNC option. */ |
| 614 | if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"sync")) { |
| 615 | *flags = EMPTYDB_NO_FLAGS; |
| 616 | } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"async")) { |
| 617 | *flags = EMPTYDB_ASYNC; |
| 618 | } else if (c->argc == 1) { |
| 619 | *flags = server.lazyfree_lazy_user_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS; |
| 620 | } else { |
| 621 | addReplyErrorObject(c,shared.syntaxerr); |
| 622 | return C_ERR; |
| 623 | } |
| 624 | return C_OK; |
| 625 | } |
| 626 | |
| 627 | /* Flushes the whole server data set. */ |
| 628 | void flushAllDataAndResetRDB(int flags) { |
no test coverage detected