MCPcopy Create free account
hub / github.com/F-Stack/f-stack / restoreDbBackup

Function restoreDbBackup

app/redis-6.2.6/src/db.c:523–549  ·  view source on GitHub ↗

Restore the previously created backup (discarding what currently resides * in the db). * This function should be called after the current contents of the database * was emptied with a previous call to emptyDb (possibly using the async mode). */

Source from the content-addressed store, hash-verified

521 * This function should be called after the current contents of the database
522 * was emptied with a previous call to emptyDb (possibly using the async mode). */
523void restoreDbBackup(dbBackup *buckup) {
524 /* Restore main DBs. */
525 for (int i=0; i<server.dbnum; i++) {
526 serverAssert(dictSize(server.db[i].dict) == 0);
527 serverAssert(dictSize(server.db[i].expires) == 0);
528 dictRelease(server.db[i].dict);
529 dictRelease(server.db[i].expires);
530 server.db[i] = buckup->dbarray[i];
531 }
532
533 /* Restore slots to keys map backup if enable cluster. */
534 if (server.cluster_enabled) {
535 serverAssert(server.cluster->slots_to_keys->numele == 0);
536 raxFree(server.cluster->slots_to_keys);
537 server.cluster->slots_to_keys = buckup->slots_to_keys;
538 memcpy(server.cluster->slots_keys_count, buckup->slots_keys_count,
539 sizeof(server.cluster->slots_keys_count));
540 }
541
542 /* Release buckup. */
543 zfree(buckup->dbarray);
544 zfree(buckup);
545
546 moduleFireServerEvent(REDISMODULE_EVENT_REPL_BACKUP,
547 REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE,
548 NULL);
549}
550
551int selectDb(client *c, int id) {
552 if (id < 0 || id >= server.dbnum)

Callers 1

Calls 5

raxFreeFunction · 0.85
moduleFireServerEventFunction · 0.85
dictReleaseFunction · 0.70
zfreeFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected