Lines Matching refs:c
36 void sunionDiffGenericCommand(client *c, robj **setkeys, int setnum,
272 void saddCommand(client *c) { in saddCommand() argument
276 set = lookupKeyWrite(c->db,c->argv[1]); in saddCommand()
278 set = setTypeCreate(c->argv[2]); in saddCommand()
279 dbAdd(c->db,c->argv[1],set); in saddCommand()
282 addReply(c,shared.wrongtypeerr); in saddCommand()
287 for (j = 2; j < c->argc; j++) { in saddCommand()
288 c->argv[j] = tryObjectEncoding(c->argv[j]); in saddCommand()
289 if (setTypeAdd(set,c->argv[j])) added++; in saddCommand()
292 signalModifiedKey(c->db,c->argv[1]); in saddCommand()
293 notifyKeyspaceEvent(NOTIFY_SET,"sadd",c->argv[1],c->db->id); in saddCommand()
296 addReplyLongLong(c,added); in saddCommand()
299 void sremCommand(client *c) { in sremCommand() argument
303 if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL || in sremCommand()
304 checkType(c,set,OBJ_SET)) return; in sremCommand()
306 for (j = 2; j < c->argc; j++) { in sremCommand()
307 if (setTypeRemove(set,c->argv[j])) { in sremCommand()
310 dbDelete(c->db,c->argv[1]); in sremCommand()
317 signalModifiedKey(c->db,c->argv[1]); in sremCommand()
318 notifyKeyspaceEvent(NOTIFY_SET,"srem",c->argv[1],c->db->id); in sremCommand()
320 notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1], in sremCommand()
321 c->db->id); in sremCommand()
324 addReplyLongLong(c,deleted); in sremCommand()
327 void smoveCommand(client *c) { in smoveCommand() argument
329 srcset = lookupKeyWrite(c->db,c->argv[1]); in smoveCommand()
330 dstset = lookupKeyWrite(c->db,c->argv[2]); in smoveCommand()
331 ele = c->argv[3] = tryObjectEncoding(c->argv[3]); in smoveCommand()
335 addReply(c,shared.czero); in smoveCommand()
341 if (checkType(c,srcset,OBJ_SET) || in smoveCommand()
342 (dstset && checkType(c,dstset,OBJ_SET))) return; in smoveCommand()
346 addReply(c,setTypeIsMember(srcset,ele) ? shared.cone : shared.czero); in smoveCommand()
352 addReply(c,shared.czero); in smoveCommand()
355 notifyKeyspaceEvent(NOTIFY_SET,"srem",c->argv[1],c->db->id); in smoveCommand()
359 dbDelete(c->db,c->argv[1]); in smoveCommand()
360 notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id); in smoveCommand()
366 dbAdd(c->db,c->argv[2],dstset); in smoveCommand()
369 signalModifiedKey(c->db,c->argv[1]); in smoveCommand()
370 signalModifiedKey(c->db,c->argv[2]); in smoveCommand()
376 notifyKeyspaceEvent(NOTIFY_SET,"sadd",c->argv[2],c->db->id); in smoveCommand()
378 addReply(c,shared.cone); in smoveCommand()
381 void sismemberCommand(client *c) { in sismemberCommand() argument
384 if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL || in sismemberCommand()
385 checkType(c,set,OBJ_SET)) return; in sismemberCommand()
387 c->argv[2] = tryObjectEncoding(c->argv[2]); in sismemberCommand()
388 if (setTypeIsMember(set,c->argv[2])) in sismemberCommand()
389 addReply(c,shared.cone); in sismemberCommand()
391 addReply(c,shared.czero); in sismemberCommand()
394 void scardCommand(client *c) { in scardCommand() argument
397 if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL || in scardCommand()
398 checkType(c,o,OBJ_SET)) return; in scardCommand()
400 addReplyLongLong(c,setTypeSize(o)); in scardCommand()
411 void spopWithCountCommand(client *c) { in spopWithCountCommand() argument
417 if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return; in spopWithCountCommand()
421 addReply(c,shared.outofrangeerr); in spopWithCountCommand()
427 if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) in spopWithCountCommand()
428 == NULL || checkType(c,set,OBJ_SET)) return; in spopWithCountCommand()
433 addReply(c,shared.emptymultibulk); in spopWithCountCommand()
440 notifyKeyspaceEvent(NOTIFY_SET,"spop",c->argv[1],c->db->id); in spopWithCountCommand()
448 sunionDiffGenericCommand(c,c->argv+1,1,NULL,SET_OP_UNION); in spopWithCountCommand()
451 dbDelete(c->db,c->argv[1]); in spopWithCountCommand()
452 notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id); in spopWithCountCommand()
455 rewriteClientCommandVector(c,2,shared.del,c->argv[1]); in spopWithCountCommand()
456 signalModifiedKey(c->db,c->argv[1]); in spopWithCountCommand()
466 propargv[1] = c->argv[1]; in spopWithCountCommand()
467 addReplyMultiBulkLen(c,count); in spopWithCountCommand()
492 addReplyBulk(c,objele); in spopWithCountCommand()
497 alsoPropagate(server.sremCommand,c->db->id,propargv,3, in spopWithCountCommand()
528 dbOverwrite(c->db,c->argv[1],newset); in spopWithCountCommand()
539 addReplyBulk(c,objele); in spopWithCountCommand()
543 alsoPropagate(server.sremCommand,c->db->id,propargv,3, in spopWithCountCommand()
557 preventCommandPropagation(c); in spopWithCountCommand()
558 signalModifiedKey(c->db,c->argv[1]); in spopWithCountCommand()
562 void spopCommand(client *c) { in spopCommand() argument
567 if (c->argc == 3) { in spopCommand()
568 spopWithCountCommand(c); in spopCommand()
570 } else if (c->argc > 3) { in spopCommand()
571 addReply(c,shared.syntaxerr); in spopCommand()
577 if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk)) == NULL || in spopCommand()
578 checkType(c,set,OBJ_SET)) return; in spopCommand()
592 notifyKeyspaceEvent(NOTIFY_SET,"spop",c->argv[1],c->db->id); in spopCommand()
596 rewriteClientCommandVector(c,3,aux,c->argv[1],ele); in spopCommand()
601 addReplyBulk(c,ele); in spopCommand()
605 dbDelete(c->db,c->argv[1]); in spopCommand()
606 notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id); in spopCommand()
610 signalModifiedKey(c->db,c->argv[1]); in spopCommand()
622 void srandmemberWithCountCommand(client *c) { in srandmemberWithCountCommand() argument
632 if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return; in srandmemberWithCountCommand()
642 if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) in srandmemberWithCountCommand()
643 == NULL || checkType(c,set,OBJ_SET)) return; in srandmemberWithCountCommand()
648 addReply(c,shared.emptymultibulk); in srandmemberWithCountCommand()
657 addReplyMultiBulkLen(c,count); in srandmemberWithCountCommand()
661 addReplyBulkLongLong(c,llele); in srandmemberWithCountCommand()
663 addReplyBulk(c,ele); in srandmemberWithCountCommand()
673 sunionDiffGenericCommand(c,c->argv+1,1,NULL,SET_OP_UNION); in srandmemberWithCountCommand()
746 addReplyMultiBulkLen(c,count); in srandmemberWithCountCommand()
749 addReplyBulk(c,dictGetKey(de)); in srandmemberWithCountCommand()
755 void srandmemberCommand(client *c) { in srandmemberCommand() argument
760 if (c->argc == 3) { in srandmemberCommand()
761 srandmemberWithCountCommand(c); in srandmemberCommand()
763 } else if (c->argc > 3) { in srandmemberCommand()
764 addReply(c,shared.syntaxerr); in srandmemberCommand()
768 if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL || in srandmemberCommand()
769 checkType(c,set,OBJ_SET)) return; in srandmemberCommand()
773 addReplyBulkLongLong(c,llele); in srandmemberCommand()
775 addReplyBulk(c,ele); in srandmemberCommand()
791 void sinterGenericCommand(client *c, robj **setkeys, in sinterGenericCommand() argument
803 lookupKeyWrite(c->db,setkeys[j]) : in sinterGenericCommand()
804 lookupKeyRead(c->db,setkeys[j]); in sinterGenericCommand()
808 if (dbDelete(c->db,dstkey)) { in sinterGenericCommand()
809 signalModifiedKey(c->db,dstkey); in sinterGenericCommand()
812 addReply(c,shared.czero); in sinterGenericCommand()
814 addReply(c,shared.emptymultibulk); in sinterGenericCommand()
818 if (checkType(c,setobj,OBJ_SET)) { in sinterGenericCommand()
834 replylen = addDeferredMultiBulkLength(c); in sinterGenericCommand()
886 addReplyBulk(c,eleobj); in sinterGenericCommand()
888 addReplyBulkLongLong(c,intobj); in sinterGenericCommand()
906 int deleted = dbDelete(c->db,dstkey); in sinterGenericCommand()
908 dbAdd(c->db,dstkey,dstset); in sinterGenericCommand()
909 addReplyLongLong(c,setTypeSize(dstset)); in sinterGenericCommand()
911 dstkey,c->db->id); in sinterGenericCommand()
914 addReply(c,shared.czero); in sinterGenericCommand()
917 dstkey,c->db->id); in sinterGenericCommand()
919 signalModifiedKey(c->db,dstkey); in sinterGenericCommand()
922 setDeferredMultiBulkLength(c,replylen,cardinality); in sinterGenericCommand()
927 void sinterCommand(client *c) { in sinterCommand() argument
928 sinterGenericCommand(c,c->argv+1,c->argc-1,NULL); in sinterCommand()
931 void sinterstoreCommand(client *c) { in sinterstoreCommand() argument
932 sinterGenericCommand(c,c->argv+2,c->argc-2,c->argv[1]); in sinterstoreCommand()
939 void sunionDiffGenericCommand(client *c, robj **setkeys, int setnum, in sunionDiffGenericCommand() argument
949 lookupKeyWrite(c->db,setkeys[j]) : in sunionDiffGenericCommand()
950 lookupKeyRead(c->db,setkeys[j]); in sunionDiffGenericCommand()
955 if (checkType(c,setobj,OBJ_SET)) { in sunionDiffGenericCommand()
1067 addReplyMultiBulkLen(c,cardinality); in sunionDiffGenericCommand()
1070 addReplyBulk(c,ele); in sunionDiffGenericCommand()
1078 int deleted = dbDelete(c->db,dstkey); in sunionDiffGenericCommand()
1080 dbAdd(c->db,dstkey,dstset); in sunionDiffGenericCommand()
1081 addReplyLongLong(c,setTypeSize(dstset)); in sunionDiffGenericCommand()
1084 dstkey,c->db->id); in sunionDiffGenericCommand()
1087 addReply(c,shared.czero); in sunionDiffGenericCommand()
1090 dstkey,c->db->id); in sunionDiffGenericCommand()
1092 signalModifiedKey(c->db,dstkey); in sunionDiffGenericCommand()
1098 void sunionCommand(client *c) { in sunionCommand() argument
1099 sunionDiffGenericCommand(c,c->argv+1,c->argc-1,NULL,SET_OP_UNION); in sunionCommand()
1102 void sunionstoreCommand(client *c) { in sunionstoreCommand() argument
1103 sunionDiffGenericCommand(c,c->argv+2,c->argc-2,c->argv[1],SET_OP_UNION); in sunionstoreCommand()
1106 void sdiffCommand(client *c) { in sdiffCommand() argument
1107 sunionDiffGenericCommand(c,c->argv+1,c->argc-1,NULL,SET_OP_DIFF); in sdiffCommand()
1110 void sdiffstoreCommand(client *c) { in sdiffstoreCommand() argument
1111 sunionDiffGenericCommand(c,c->argv+2,c->argc-2,c->argv[1],SET_OP_DIFF); in sdiffstoreCommand()
1114 void sscanCommand(client *c) { in sscanCommand() argument
1118 if (parseScanCursorOrReply(c,c->argv[2],&cursor) == C_ERR) return; in sscanCommand()
1119 if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL || in sscanCommand()
1120 checkType(c,set,OBJ_SET)) return; in sscanCommand()
1121 scanGenericCommand(c,set,cursor); in sscanCommand()