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

Function dbUnshareStringValue

src/db.cpp:555–564  ·  view source on GitHub ↗

Prepare the string object stored at 'key' to be modified destructively * to implement commands like SETBIT or APPEND. * * An object is usually ready to be modified unless one of the two conditions * are true: * * 1) The object 'o' is shared (refcount > 1), we don't want to affect * other users. * 2) The object encoding is not "RAW". * * If the object is found in one of the above condi

Source from the content-addressed store, hash-verified

553 * using an sdscat() call to append some data, or anything else.
554 */
555robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) {
556 serverAssert(o->type == OBJ_STRING);
557 if (o->getrefcount(std::memory_order_relaxed) != 1 || o->encoding != OBJ_ENCODING_RAW) {
558 robj *decoded = getDecodedObject(o);
559 o = createRawStringObject(szFromObj(decoded), sdslen(szFromObj(decoded)));
560 decrRefCount(decoded);
561 dbOverwrite(db,key,o);
562 }
563 return o;
564}
565
566/* Remove all keys from the database(s) structure. The dbarray argument
567 * may not be the server main DBs (could be a backup).

Callers 9

RM_StringDMAFunction · 0.85
RM_StringTruncateFunction · 0.85
setrangeCommandFunction · 0.85
appendCommandFunction · 0.85
pfaddCommandFunction · 0.85
pfcountCommandFunction · 0.85
pfmergeCommandFunction · 0.85
pfdebugCommandFunction · 0.85

Calls 7

getDecodedObjectFunction · 0.85
createRawStringObjectFunction · 0.85
szFromObjFunction · 0.85
sdslenFunction · 0.85
decrRefCountFunction · 0.85
dbOverwriteFunction · 0.85
getrefcountMethod · 0.80

Tested by

no test coverage detected