MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / getFlushCommandFlags

Function getFlushCommandFlags

src/db.cpp:787–800  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

785 * On success C_OK is returned and the flags are stored in *flags, otherwise
786 * C_ERR is returned and the function sends an error to the client. */
787int getFlushCommandFlags(client *c, int *flags) {
788 /* Parse the optional ASYNC option. */
789 if (c->argc == 2 && !strcasecmp(szFromObj(c->argv[1]),"sync")) {
790 *flags = EMPTYDB_NO_FLAGS;
791 } else if (c->argc == 2 && !strcasecmp(szFromObj(c->argv[1]),"async")) {
792 *flags = EMPTYDB_ASYNC;
793 } else if (c->argc == 1) {
794 *flags = g_pserver->lazyfree_lazy_user_flush ? EMPTYDB_ASYNC : EMPTYDB_NO_FLAGS;
795 } else {
796 addReplyErrorObject(c,shared.syntaxerr);
797 return C_ERR;
798 }
799 return C_OK;
800}
801
802/* Flushes the whole server data set. */
803void flushAllDataAndResetRDB(int flags) {

Callers 2

flushdbCommandFunction · 0.85
flushallCommandFunction · 0.85

Calls 2

szFromObjFunction · 0.85
addReplyErrorObjectFunction · 0.85

Tested by

no test coverage detected