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

Function emptyDbStructure

src/db.cpp:572–593  ·  view source on GitHub ↗

Remove all keys from the database(s) structure. The dbarray argument * may not be the server main DBs (could be a backup). * * The dbnum can be -1 if all the DBs should be emptied, or the specified * DB index if we want to empty only a single database. * The function returns the number of keys removed from the database(s). */

Source from the content-addressed store, hash-verified

570 * DB index if we want to empty only a single database.
571 * The function returns the number of keys removed from the database(s). */
572long long emptyDbStructure(redisDb **dbarray, int dbnum, int async,
573 void(callback)(void*))
574{
575 long long removed = 0;
576 int startdb, enddb;
577
578 if (dbnum == -1) {
579 startdb = 0;
580 enddb = cserver.dbnum-1;
581 } else {
582 startdb = enddb = dbnum;
583 }
584
585 for (int j = startdb; j <= enddb; j++) {
586 removed += dbarray[j]->size();
587 dbarray[j]->clear(async, callback);
588 /* Because all keys of database are removed, reset average ttl. */
589 dbarray[j]->avg_ttl = 0;
590 }
591
592 return removed;
593}
594
595/* Remove all keys from all the databases in a Redis DB.
596 * If callback is given the function is called from time to time to

Callers 1

emptyDbFunction · 0.85

Calls 2

sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected