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

Function genericSetKey

src/db.cpp:410–418  ·  view source on GitHub ↗

High level Set operation. This function can be used in order to set * a key, whatever it was existing or not, to a new object. * * 1) The ref count of the value object is incremented. * 2) clients WATCHing for the destination key notified. * 3) The expire time of the key is reset (the key is made persistent), * unless 'keepttl' is true. * * All the new keys in the database should be cre

Source from the content-addressed store, hash-verified

408 * The client 'c' argument may be set to NULL if the operation is performed
409 * in a context where there is no clear client performing the operation. */
410void genericSetKey(client *c, redisDb *db, robj *key, robj *val, int keepttl, int signal) {
411 db->prepOverwriteForSnapshot(szFromObj(key));
412 dict_iter iter;
413 if (!dbAddCore(db, szFromObj(key), val, true /* fUpdateMvcc */, false /*fAssumeNew*/, &iter)) {
414 dbOverwrite(db, key, val, !keepttl, &iter);
415 }
416 incrRefCount(val);
417 if (signal) signalModifiedKey(c,db,key);
418}
419
420/* Common case for genericSetKey() where the TTL is not retained. */
421void setKey(client *c, redisDb *db, robj *key, robj *val) {

Callers 5

setKeyFunction · 0.85
RM_StringSetFunction · 0.85
RM_StringTruncateFunction · 0.85
RM_ModuleTypeSetValueFunction · 0.85
setGenericCommandFunction · 0.85

Calls 6

szFromObjFunction · 0.85
dbAddCoreFunction · 0.85
dbOverwriteFunction · 0.85
incrRefCountFunction · 0.85
signalModifiedKeyFunction · 0.85

Tested by

no test coverage detected