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

Function msetGenericCommand

src/t_string.cpp:547–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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