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

Function saddCommand

src/t_set.cpp:308–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void saddCommand(client *c) {
309 robj *set;
310 int j, added = 0;
311
312 set = lookupKeyWrite(c->db,c->argv[1]);
313 if (checkType(c,set,OBJ_SET)) return;
314
315 if (set == NULL) {
316 set = setTypeCreate(szFromObj(c->argv[2]));
317 dbAdd(c->db,c->argv[1],set);
318 }
319
320 for (j = 2; j < c->argc; j++) {
321 if (setTypeAdd(set,szFromObj(c->argv[j]))) added++;
322 }
323 if (added) {
324 signalModifiedKey(c,c->db,c->argv[1]);
325 notifyKeyspaceEvent(NOTIFY_SET,"sadd",c->argv[1],c->db->id);
326 }
327 g_pserver->dirty += added;
328 addReplyLongLong(c,added);
329}
330
331void sremCommand(client *c) {
332 robj *set;

Callers

nothing calls this directly

Calls 9

lookupKeyWriteFunction · 0.85
checkTypeFunction · 0.85
setTypeCreateFunction · 0.85
szFromObjFunction · 0.85
dbAddFunction · 0.85
setTypeAddFunction · 0.85
signalModifiedKeyFunction · 0.85
notifyKeyspaceEventFunction · 0.85
addReplyLongLongFunction · 0.85

Tested by

no test coverage detected