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

Function msetGenericCommand

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

Source from the content-addressed store, hash-verified

541}
542
543void msetGenericCommand(client *c, int nx) {
544 int j;
545
546 if ((c->argc % 2) == 0) {
547 addReplyError(c,"wrong number of arguments for MSET");
548 return;
549 }
550
551 /* Handle the NX flag. The MSETNX semantic is to return zero and don't
552 * set anything if at least one key already exists. */
553 if (nx) {
554 for (j = 1; j < c->argc; j += 2) {
555 if (lookupKeyWrite(c->db,c->argv[j]) != NULL) {
556 addReply(c, shared.czero);
557 return;
558 }
559 }
560 }
561
562 for (j = 1; j < c->argc; j += 2) {
563 c->argv[j+1] = tryObjectEncoding(c->argv[j+1]);
564 setKey(c,c->db,c->argv[j],c->argv[j+1]);
565 notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id);
566 }
567 server.dirty += (c->argc-1)/2;
568 addReply(c, nx ? shared.cone : shared.ok);
569}
570
571void msetCommand(client *c) {
572 msetGenericCommand(c,0);

Callers 2

msetCommandFunction · 0.85
msetnxCommandFunction · 0.85

Calls 6

addReplyErrorFunction · 0.85
lookupKeyWriteFunction · 0.85
addReplyFunction · 0.85
tryObjectEncodingFunction · 0.85
setKeyFunction · 0.85
notifyKeyspaceEventFunction · 0.85

Tested by

no test coverage detected