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

Function discardDbBackup

src/db.cpp:677–696  ·  view source on GitHub ↗

Discard a previously created backup, this can be slow (similar to FLUSHALL) * Arguments are similar to the ones of emptyDb, see EMPTYDB_ flags. */

Source from the content-addressed store, hash-verified

675/* Discard a previously created backup, this can be slow (similar to FLUSHALL)
676 * Arguments are similar to the ones of emptyDb, see EMPTYDB_ flags. */
677void discardDbBackup(const dbBackup *backup, int flags, void(callback)(void*)) {
678 UNUSED(callback);
679 int async = (flags & EMPTYDB_ASYNC);
680
681 /* Release main DBs backup . */
682 for (int i=0; i<cserver.dbnum; i++) {
683 g_pserver->db[i]->endSnapshot(backup->dbarray[i]);
684 }
685
686 /* Release slots to keys map backup if enable cluster. */
687 if (g_pserver->cluster_enabled) freeSlotsToKeysMap(backup->slots_to_keys, async);
688
689 /* Release buckup. */
690 zfree(backup->dbarray);
691 delete backup;
692
693 moduleFireServerEvent(REDISMODULE_EVENT_REPL_BACKUP,
694 REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD,
695 NULL);
696}
697
698/* Restore the previously created backup (discarding what currently resides
699 * in the db).

Callers 1

Calls 4

freeSlotsToKeysMapFunction · 0.85
zfreeFunction · 0.85
moduleFireServerEventFunction · 0.85
endSnapshotMethod · 0.80

Tested by

no test coverage detected