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

Function dbAddCore

src/db.cpp:284–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284bool dbAddCore(redisDb *db, sds key, robj *val, bool fUpdateMvcc, bool fAssumeNew = false, dict_iter *piterExisting = nullptr, bool fValExpires = false) {
285 serverAssert(fValExpires || !val->FExpires());
286 sds copy = sdsdupshared(key);
287
288 uint64_t mvcc = getMvccTstamp();
289 if (fUpdateMvcc) {
290 setMvccTstamp(val, mvcc);
291 }
292
293 bool fInserted = db->insert(copy, val, fAssumeNew, piterExisting);
294
295 if (fInserted)
296 {
297 signalKeyAsReady(db, key, val->type);
298 if (g_pserver->cluster_enabled) slotToKeyAdd(key);
299 }
300 else
301 {
302 sdsfree(copy);
303 }
304
305 return fInserted;
306}
307
308/* Add the key to the DB. It's up to the caller to increment the reference
309 * counter of the value if needed.

Callers 5

dbAddFunction · 0.85
dbMergeFunction · 0.85
genericSetKeyFunction · 0.85
renameGenericCommandFunction · 0.85
moveCommandFunction · 0.85

Calls 8

sdsdupsharedFunction · 0.85
getMvccTstampFunction · 0.85
setMvccTstampFunction · 0.85
signalKeyAsReadyFunction · 0.85
slotToKeyAddFunction · 0.85
sdsfreeFunction · 0.85
FExpiresMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected