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

Function appendCommand

app/redis-6.2.6/src/t_string.c:672–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670}
671
672void appendCommand(client *c) {
673 size_t totlen;
674 robj *o, *append;
675
676 o = lookupKeyWrite(c->db,c->argv[1]);
677 if (o == NULL) {
678 /* Create the key */
679 c->argv[2] = tryObjectEncoding(c->argv[2]);
680 dbAdd(c->db,c->argv[1],c->argv[2]);
681 incrRefCount(c->argv[2]);
682 totlen = stringObjectLen(c->argv[2]);
683 } else {
684 /* Key exists, check type */
685 if (checkType(c,o,OBJ_STRING))
686 return;
687
688 /* "append" is an argument, so always an sds */
689 append = c->argv[2];
690 totlen = stringObjectLen(o)+sdslen(append->ptr);
691 if (checkStringLength(c,totlen) != C_OK)
692 return;
693
694 /* Append the value */
695 o = dbUnshareStringValue(c->db,c->argv[1],o);
696 o->ptr = sdscatlen(o->ptr,append->ptr,sdslen(append->ptr));
697 totlen = sdslen(o->ptr);
698 }
699 signalModifiedKey(c,c->db,c->argv[1]);
700 notifyKeyspaceEvent(NOTIFY_STRING,"append",c->argv[1],c->db->id);
701 server.dirty++;
702 addReplyLongLong(c,totlen);
703}
704
705void strlenCommand(client *c) {
706 robj *o;

Callers

nothing calls this directly

Calls 13

lookupKeyWriteFunction · 0.85
tryObjectEncodingFunction · 0.85
dbAddFunction · 0.85
incrRefCountFunction · 0.85
stringObjectLenFunction · 0.85
checkTypeFunction · 0.85
sdslenFunction · 0.85
checkStringLengthFunction · 0.85
dbUnshareStringValueFunction · 0.85
sdscatlenFunction · 0.85
signalModifiedKeyFunction · 0.85
notifyKeyspaceEventFunction · 0.85

Tested by

no test coverage detected