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

Function genericSetKey

app/redis-6.2.6/src/db.c:259–268  ·  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

257 * The client 'c' argument may be set to NULL if the operation is performed
258 * in a context where there is no clear client performing the operation. */
259void genericSetKey(client *c, redisDb *db, robj *key, robj *val, int keepttl, int signal) {
260 if (lookupKeyWrite(db,key) == NULL) {
261 dbAdd(db,key,val);
262 } else {
263 dbOverwrite(db,key,val);
264 }
265 incrRefCount(val);
266 if (!keepttl) removeExpire(db,key);
267 if (signal) signalModifiedKey(c,db,key);
268}
269
270/* Common case for genericSetKey() where the TTL is not retained. */
271void setKey(client *c, redisDb *db, robj *key, robj *val) {

Callers 5

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

Calls 6

lookupKeyWriteFunction · 0.85
dbAddFunction · 0.85
dbOverwriteFunction · 0.85
incrRefCountFunction · 0.85
removeExpireFunction · 0.85
signalModifiedKeyFunction · 0.85

Tested by

no test coverage detected