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

Function dbOverwrite

src/db.cpp:363–373  ·  view source on GitHub ↗

Overwrite an existing key with a new value. Incrementing the reference * count of the new value is up to the caller. * This function does not modify the expire time of the existing key. * * The program is aborted if the key was not already present. */

Source from the content-addressed store, hash-verified

361 *
362 * The program is aborted if the key was not already present. */
363void dbOverwrite(redisDb *db, robj *key, robj *val, bool fRemoveExpire, dict_iter *pitrExisting) {
364 redisDb::iter itr;
365 if (pitrExisting != nullptr)
366 itr = *pitrExisting;
367 else
368 itr = db->find(key);
369
370 serverAssertWithInfo(NULL,key,itr != nullptr);
371 lookupKeyUpdateObj(itr.val(), LOOKUP_NONE);
372 db->dbOverwriteCore(itr, szFromObj(key), val, !!g_pserver->fActiveReplica, fRemoveExpire);
373}
374
375/* Insert a key, handling duplicate keys according to fReplace */
376int dbMerge(redisDb *db, sds key, robj *val, int fReplace)

Callers 5

genericSetKeyFunction · 0.85
dbUnshareStringValueFunction · 0.85
spopWithCountCommandFunction · 0.85
incrDecrCommandFunction · 0.85
incrbyfloatCommandFunction · 0.85

Calls 5

lookupKeyUpdateObjFunction · 0.85
szFromObjFunction · 0.85
dbOverwriteCoreMethod · 0.80
findMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected