3 /*-----------------------------------------------------------------------------
5 *----------------------------------------------------------------------------*/
7 void sunionDiffGenericCommand(redisClient
*c
, robj
**setkeys
, int setnum
, robj
*dstkey
, int op
);
9 /* Factory method to return a set that *can* hold "value". When the object has
10 * an integer-encodable value, an intset will be returned. Otherwise a regular
12 robj
*setTypeCreate(robj
*value
) {
13 if (isObjectRepresentableAsLongLong(value
,NULL
) == REDIS_OK
)
14 return createIntsetObject();
15 return createSetObject();
18 int setTypeAdd(robj
*subject
, robj
*value
) {
20 if (subject
->encoding
== REDIS_ENCODING_HT
) {
21 if (dictAdd(subject
->ptr
,value
,NULL
) == DICT_OK
) {
25 } else if (subject
->encoding
== REDIS_ENCODING_INTSET
) {
26 if (isObjectRepresentableAsLongLong(value
,&llval
) == REDIS_OK
) {
28 subject
->ptr
= intsetAdd(subject
->ptr
,llval
,&success
);
30 /* Convert to regular set when the intset contains
31 * too many entries. */
32 if (intsetLen(subject
->ptr
) > server
.set_max_intset_entries
)
33 setTypeConvert(subject
,REDIS_ENCODING_HT
);
37 /* Failed to get integer from object, convert to regular set. */
38 setTypeConvert(subject
,REDIS_ENCODING_HT
);
40 /* The set *was* an intset and this value is not integer
41 * encodable, so dictAdd should always work. */
42 redisAssertWithInfo(NULL
,value
,dictAdd(subject
->ptr
,value
,NULL
) == DICT_OK
);
47 redisPanic("Unknown set encoding");
52 int setTypeRemove(robj
*setobj
, robj
*value
) {
54 if (setobj
->encoding
== REDIS_ENCODING_HT
) {
55 if (dictDelete(setobj
->ptr
,value
) == DICT_OK
) {
56 if (htNeedsResize(setobj
->ptr
)) dictResize(setobj
->ptr
);
59 } else if (setobj
->encoding
== REDIS_ENCODING_INTSET
) {
60 if (isObjectRepresentableAsLongLong(value
,&llval
) == REDIS_OK
) {
62 setobj
->ptr
= intsetRemove(setobj
->ptr
,llval
,&success
);
63 if (success
) return 1;
66 redisPanic("Unknown set encoding");
71 int setTypeIsMember(robj
*subject
, robj
*value
) {
73 if (subject
->encoding
== REDIS_ENCODING_HT
) {
74 return dictFind((dict
*)subject
->ptr
,value
) != NULL
;
75 } else if (subject
->encoding
== REDIS_ENCODING_INTSET
) {
76 if (isObjectRepresentableAsLongLong(value
,&llval
) == REDIS_OK
) {
77 return intsetFind((intset
*)subject
->ptr
,llval
);
80 redisPanic("Unknown set encoding");
85 setTypeIterator
*setTypeInitIterator(robj
*subject
) {
86 setTypeIterator
*si
= zmalloc(sizeof(setTypeIterator
));
87 si
->subject
= subject
;
88 si
->encoding
= subject
->encoding
;
89 if (si
->encoding
== REDIS_ENCODING_HT
) {
90 si
->di
= dictGetIterator(subject
->ptr
);
91 } else if (si
->encoding
== REDIS_ENCODING_INTSET
) {
94 redisPanic("Unknown set encoding");
99 void setTypeReleaseIterator(setTypeIterator
*si
) {
100 if (si
->encoding
== REDIS_ENCODING_HT
)
101 dictReleaseIterator(si
->di
);
105 /* Move to the next entry in the set. Returns the object at the current
108 * Since set elements can be internally be stored as redis objects or
109 * simple arrays of integers, setTypeNext returns the encoding of the
110 * set object you are iterating, and will populate the appropriate pointer
111 * (eobj) or (llobj) accordingly.
113 * When there are no longer elements -1 is returned.
114 * Returned objects ref count is not incremented, so this function is
115 * copy on write friendly. */
116 int setTypeNext(setTypeIterator
*si
, robj
**objele
, int64_t *llele
) {
117 if (si
->encoding
== REDIS_ENCODING_HT
) {
118 dictEntry
*de
= dictNext(si
->di
);
119 if (de
== NULL
) return -1;
120 *objele
= dictGetKey(de
);
121 } else if (si
->encoding
== REDIS_ENCODING_INTSET
) {
122 if (!intsetGet(si
->subject
->ptr
,si
->ii
++,llele
))
128 /* The not copy on write friendly version but easy to use version
129 * of setTypeNext() is setTypeNextObject(), returning new objects
130 * or incrementing the ref count of returned objects. So if you don't
131 * retain a pointer to this object you should call decrRefCount() against it.
133 * This function is the way to go for write operations where COW is not
134 * an issue as the result will be anyway of incrementing the ref count. */
135 robj
*setTypeNextObject(setTypeIterator
*si
) {
140 encoding
= setTypeNext(si
,&objele
,&intele
);
142 case -1: return NULL
;
143 case REDIS_ENCODING_INTSET
:
144 return createStringObjectFromLongLong(intele
);
145 case REDIS_ENCODING_HT
:
146 incrRefCount(objele
);
149 redisPanic("Unsupported encoding");
151 return NULL
; /* just to suppress warnings */
154 /* Return random element from a non empty set.
155 * The returned element can be a int64_t value if the set is encoded
156 * as an "intset" blob of integers, or a redis object if the set
159 * The caller provides both pointers to be populated with the right
160 * object. The return value of the function is the object->encoding
161 * field of the object and is used by the caller to check if the
162 * int64_t pointer or the redis object pointere was populated.
164 * When an object is returned (the set was a real set) the ref count
165 * of the object is not incremented so this function can be considered
166 * copy on write friendly. */
167 int setTypeRandomElement(robj
*setobj
, robj
**objele
, int64_t *llele
) {
168 if (setobj
->encoding
== REDIS_ENCODING_HT
) {
169 dictEntry
*de
= dictGetRandomKey(setobj
->ptr
);
170 *objele
= dictGetKey(de
);
171 } else if (setobj
->encoding
== REDIS_ENCODING_INTSET
) {
172 *llele
= intsetRandom(setobj
->ptr
);
174 redisPanic("Unknown set encoding");
176 return setobj
->encoding
;
179 unsigned long setTypeSize(robj
*subject
) {
180 if (subject
->encoding
== REDIS_ENCODING_HT
) {
181 return dictSize((dict
*)subject
->ptr
);
182 } else if (subject
->encoding
== REDIS_ENCODING_INTSET
) {
183 return intsetLen((intset
*)subject
->ptr
);
185 redisPanic("Unknown set encoding");
189 /* Convert the set to specified encoding. The resulting dict (when converting
190 * to a hashtable) is presized to hold the number of elements in the original
192 void setTypeConvert(robj
*setobj
, int enc
) {
194 redisAssertWithInfo(NULL
,setobj
,setobj
->type
== REDIS_SET
&&
195 setobj
->encoding
== REDIS_ENCODING_INTSET
);
197 if (enc
== REDIS_ENCODING_HT
) {
199 dict
*d
= dictCreate(&setDictType
,NULL
);
202 /* Presize the dict to avoid rehashing */
203 dictExpand(d
,intsetLen(setobj
->ptr
));
205 /* To add the elements we extract integers and create redis objects */
206 si
= setTypeInitIterator(setobj
);
207 while (setTypeNext(si
,NULL
,&intele
) != -1) {
208 element
= createStringObjectFromLongLong(intele
);
209 redisAssertWithInfo(NULL
,element
,dictAdd(d
,element
,NULL
) == DICT_OK
);
211 setTypeReleaseIterator(si
);
213 setobj
->encoding
= REDIS_ENCODING_HT
;
217 redisPanic("Unsupported set conversion");
221 void saddCommand(redisClient
*c
) {
225 set
= lookupKeyWrite(c
->db
,c
->argv
[1]);
227 set
= setTypeCreate(c
->argv
[2]);
228 dbAdd(c
->db
,c
->argv
[1],set
);
230 if (set
->type
!= REDIS_SET
) {
231 addReply(c
,shared
.wrongtypeerr
);
236 for (j
= 2; j
< c
->argc
; j
++) {
237 c
->argv
[j
] = tryObjectEncoding(c
->argv
[j
]);
238 if (setTypeAdd(set
,c
->argv
[j
])) added
++;
240 if (added
) signalModifiedKey(c
->db
,c
->argv
[1]);
241 server
.dirty
+= added
;
242 addReplyLongLong(c
,added
);
245 void sremCommand(redisClient
*c
) {
249 if ((set
= lookupKeyWriteOrReply(c
,c
->argv
[1],shared
.czero
)) == NULL
||
250 checkType(c
,set
,REDIS_SET
)) return;
252 for (j
= 2; j
< c
->argc
; j
++) {
253 if (setTypeRemove(set
,c
->argv
[j
])) {
255 if (setTypeSize(set
) == 0) {
256 dbDelete(c
->db
,c
->argv
[1]);
262 signalModifiedKey(c
->db
,c
->argv
[1]);
263 server
.dirty
+= deleted
;
265 addReplyLongLong(c
,deleted
);
268 void smoveCommand(redisClient
*c
) {
269 robj
*srcset
, *dstset
, *ele
;
270 srcset
= lookupKeyWrite(c
->db
,c
->argv
[1]);
271 dstset
= lookupKeyWrite(c
->db
,c
->argv
[2]);
272 ele
= c
->argv
[3] = tryObjectEncoding(c
->argv
[3]);
274 /* If the source key does not exist return 0 */
275 if (srcset
== NULL
) {
276 addReply(c
,shared
.czero
);
280 /* If the source key has the wrong type, or the destination key
281 * is set and has the wrong type, return with an error. */
282 if (checkType(c
,srcset
,REDIS_SET
) ||
283 (dstset
&& checkType(c
,dstset
,REDIS_SET
))) return;
285 /* If srcset and dstset are equal, SMOVE is a no-op */
286 if (srcset
== dstset
) {
287 addReply(c
,shared
.cone
);
291 /* If the element cannot be removed from the src set, return 0. */
292 if (!setTypeRemove(srcset
,ele
)) {
293 addReply(c
,shared
.czero
);
297 /* Remove the src set from the database when empty */
298 if (setTypeSize(srcset
) == 0) dbDelete(c
->db
,c
->argv
[1]);
299 signalModifiedKey(c
->db
,c
->argv
[1]);
300 signalModifiedKey(c
->db
,c
->argv
[2]);
303 /* Create the destination set when it doesn't exist */
305 dstset
= setTypeCreate(ele
);
306 dbAdd(c
->db
,c
->argv
[2],dstset
);
309 /* An extra key has changed when ele was successfully added to dstset */
310 if (setTypeAdd(dstset
,ele
)) server
.dirty
++;
311 addReply(c
,shared
.cone
);
314 void sismemberCommand(redisClient
*c
) {
317 if ((set
= lookupKeyReadOrReply(c
,c
->argv
[1],shared
.czero
)) == NULL
||
318 checkType(c
,set
,REDIS_SET
)) return;
320 c
->argv
[2] = tryObjectEncoding(c
->argv
[2]);
321 if (setTypeIsMember(set
,c
->argv
[2]))
322 addReply(c
,shared
.cone
);
324 addReply(c
,shared
.czero
);
327 void scardCommand(redisClient
*c
) {
330 if ((o
= lookupKeyReadOrReply(c
,c
->argv
[1],shared
.czero
)) == NULL
||
331 checkType(c
,o
,REDIS_SET
)) return;
333 addReplyLongLong(c
,setTypeSize(o
));
336 void spopCommand(redisClient
*c
) {
337 robj
*set
, *ele
, *aux
;
341 if ((set
= lookupKeyWriteOrReply(c
,c
->argv
[1],shared
.nullbulk
)) == NULL
||
342 checkType(c
,set
,REDIS_SET
)) return;
344 encoding
= setTypeRandomElement(set
,&ele
,&llele
);
345 if (encoding
== REDIS_ENCODING_INTSET
) {
346 ele
= createStringObjectFromLongLong(llele
);
347 set
->ptr
= intsetRemove(set
->ptr
,llele
,NULL
);
350 setTypeRemove(set
,ele
);
353 /* Replicate/AOF this command as an SREM operation */
354 aux
= createStringObject("SREM",4);
355 rewriteClientCommandVector(c
,3,aux
,c
->argv
[1],ele
);
360 if (setTypeSize(set
) == 0) dbDelete(c
->db
,c
->argv
[1]);
361 signalModifiedKey(c
->db
,c
->argv
[1]);
365 /* handle the "SRANDMEMBER key <count>" variant. The normal version of the
366 * command is handled by the srandmemberCommand() function itself. */
368 /* How many times bigger should be the set compared to the requested size
369 * for us to don't use the "remove elements" strategy? Read later in the
370 * implementation for more info. */
371 #define SRANDMEMBER_SUB_STRATEGY_MUL 3
373 void srandmemberWithCountCommand(redisClient
*c
) {
375 unsigned long count
, size
;
383 if (getLongFromObjectOrReply(c
,c
->argv
[2],&l
,NULL
) != REDIS_OK
) return;
385 count
= (unsigned) l
;
387 /* A negative count means: return the same elements multiple times
388 * (i.e. don't remove the extracted element after every extraction). */
393 if ((set
= lookupKeyReadOrReply(c
,c
->argv
[1],shared
.emptymultibulk
))
394 == NULL
|| checkType(c
,set
,REDIS_SET
)) return;
395 size
= setTypeSize(set
);
397 /* If count is zero, serve it ASAP to avoid special cases later. */
399 addReply(c
,shared
.emptymultibulk
);
403 /* CASE 1: The count was negative, so the extraction method is just:
404 * "return N random elements" sampling the whole set every time.
405 * This case is trivial and can be served without auxiliary data
408 addReplyMultiBulkLen(c
,count
);
410 encoding
= setTypeRandomElement(set
,&ele
,&llele
);
411 if (encoding
== REDIS_ENCODING_INTSET
) {
412 addReplyBulkLongLong(c
,llele
);
421 * The number of requested elements is greater than the number of
422 * elements inside the set: simply return the whole set. */
424 sunionDiffGenericCommand(c
,c
->argv
,c
->argc
-1,NULL
,REDIS_OP_UNION
);
428 /* For CASE 3 and CASE 4 we need an auxiliary dictionary. */
429 d
= dictCreate(&setDictType
,NULL
);
432 * The number of elements inside the set is not greater than
433 * SRANDMEMBER_SUB_STRATEGY_MUL times the number of requested elements.
434 * In this case we create a set from scratch with all the elements, and
435 * subtract random elements to reach the requested number of elements.
437 * This is done because if the number of requsted elements is just
438 * a bit less than the number of elements in the set, the natural approach
439 * used into CASE 3 is highly inefficient. */
440 if (count
*SRANDMEMBER_SUB_STRATEGY_MUL
> size
) {
443 /* Add all the elements into the temporary dictionary. */
444 si
= setTypeInitIterator(set
);
445 while((encoding
= setTypeNext(si
,&ele
,&llele
)) != -1) {
448 if (encoding
== REDIS_ENCODING_INTSET
) {
449 retval
= dictAdd(d
,createStringObjectFromLongLong(llele
),NULL
);
450 } else if (ele
->encoding
== REDIS_ENCODING_RAW
) {
451 retval
= dictAdd(d
,dupStringObject(ele
),NULL
);
452 } else if (ele
->encoding
== REDIS_ENCODING_INT
) {
454 createStringObjectFromLongLong((long)ele
->ptr
),NULL
);
456 redisAssert(retval
== DICT_OK
);
458 setTypeReleaseIterator(si
);
459 redisAssert(dictSize(d
) == size
);
461 /* Remove random elements to reach the right count. */
462 while(size
> count
) {
465 de
= dictGetRandomKey(d
);
466 dictDelete(d
,dictGetKey(de
));
471 /* CASE 4: We have a big set compared to the requested number of elements.
472 * In this case we can simply get random elements from the set and add
473 * to the temporary set, trying to eventually get enough unique elements
474 * to reach the specified count. */
476 unsigned long added
= 0;
478 while(added
< count
) {
481 encoding
= setTypeRandomElement(set
,&ele
,&llele
);
482 if (encoding
== REDIS_ENCODING_INTSET
) {
483 retval
= dictAdd(d
,createStringObjectFromLongLong(llele
),NULL
);
484 } else if (ele
->encoding
== REDIS_ENCODING_RAW
) {
485 retval
= dictAdd(d
,dupStringObject(ele
),NULL
);
486 } else if (ele
->encoding
== REDIS_ENCODING_INT
) {
488 createStringObjectFromLongLong((long)ele
->ptr
),NULL
);
491 if (retval
== DICT_OK
) added
++;
495 /* CASE 3 & 4: send the result to the user. */
500 addReplyMultiBulkLen(c
,count
);
501 di
= dictGetIterator(d
);
502 while((de
= dictNext(di
)) != NULL
)
503 addReplyBulk(c
,dictGetKey(de
));
504 dictReleaseIterator(di
);
509 void srandmemberCommand(redisClient
*c
) {
515 srandmemberWithCountCommand(c
);
517 } else if (c
->argc
> 3) {
518 addReply(c
,shared
.syntaxerr
);
522 if ((set
= lookupKeyReadOrReply(c
,c
->argv
[1],shared
.nullbulk
)) == NULL
||
523 checkType(c
,set
,REDIS_SET
)) return;
525 encoding
= setTypeRandomElement(set
,&ele
,&llele
);
526 if (encoding
== REDIS_ENCODING_INTSET
) {
527 addReplyBulkLongLong(c
,llele
);
533 int qsortCompareSetsByCardinality(const void *s1
, const void *s2
) {
534 return setTypeSize(*(robj
**)s1
)-setTypeSize(*(robj
**)s2
);
537 void sinterGenericCommand(redisClient
*c
, robj
**setkeys
, unsigned long setnum
, robj
*dstkey
) {
538 robj
**sets
= zmalloc(sizeof(robj
*)*setnum
);
540 robj
*eleobj
, *dstset
= NULL
;
542 void *replylen
= NULL
;
543 unsigned long j
, cardinality
= 0;
546 for (j
= 0; j
< setnum
; j
++) {
547 robj
*setobj
= dstkey
?
548 lookupKeyWrite(c
->db
,setkeys
[j
]) :
549 lookupKeyRead(c
->db
,setkeys
[j
]);
553 if (dbDelete(c
->db
,dstkey
)) {
554 signalModifiedKey(c
->db
,dstkey
);
557 addReply(c
,shared
.czero
);
559 addReply(c
,shared
.emptymultibulk
);
563 if (checkType(c
,setobj
,REDIS_SET
)) {
569 /* Sort sets from the smallest to largest, this will improve our
570 * algorithm's performace */
571 qsort(sets
,setnum
,sizeof(robj
*),qsortCompareSetsByCardinality
);
573 /* The first thing we should output is the total number of elements...
574 * since this is a multi-bulk write, but at this stage we don't know
575 * the intersection set size, so we use a trick, append an empty object
576 * to the output list and save the pointer to later modify it with the
579 replylen
= addDeferredMultiBulkLength(c
);
581 /* If we have a target key where to store the resulting set
582 * create this key with an empty set inside */
583 dstset
= createIntsetObject();
586 /* Iterate all the elements of the first (smallest) set, and test
587 * the element against all the other sets, if at least one set does
588 * not include the element it is discarded */
589 si
= setTypeInitIterator(sets
[0]);
590 while((encoding
= setTypeNext(si
,&eleobj
,&intobj
)) != -1) {
591 for (j
= 1; j
< setnum
; j
++) {
592 if (sets
[j
] == sets
[0]) continue;
593 if (encoding
== REDIS_ENCODING_INTSET
) {
594 /* intset with intset is simple... and fast */
595 if (sets
[j
]->encoding
== REDIS_ENCODING_INTSET
&&
596 !intsetFind((intset
*)sets
[j
]->ptr
,intobj
))
599 /* in order to compare an integer with an object we
600 * have to use the generic function, creating an object
602 } else if (sets
[j
]->encoding
== REDIS_ENCODING_HT
) {
603 eleobj
= createStringObjectFromLongLong(intobj
);
604 if (!setTypeIsMember(sets
[j
],eleobj
)) {
605 decrRefCount(eleobj
);
608 decrRefCount(eleobj
);
610 } else if (encoding
== REDIS_ENCODING_HT
) {
611 /* Optimization... if the source object is integer
612 * encoded AND the target set is an intset, we can get
613 * a much faster path. */
614 if (eleobj
->encoding
== REDIS_ENCODING_INT
&&
615 sets
[j
]->encoding
== REDIS_ENCODING_INTSET
&&
616 !intsetFind((intset
*)sets
[j
]->ptr
,(long)eleobj
->ptr
))
619 /* else... object to object check is easy as we use the
620 * type agnostic API here. */
621 } else if (!setTypeIsMember(sets
[j
],eleobj
)) {
627 /* Only take action when all sets contain the member */
630 if (encoding
== REDIS_ENCODING_HT
)
631 addReplyBulk(c
,eleobj
);
633 addReplyBulkLongLong(c
,intobj
);
636 if (encoding
== REDIS_ENCODING_INTSET
) {
637 eleobj
= createStringObjectFromLongLong(intobj
);
638 setTypeAdd(dstset
,eleobj
);
639 decrRefCount(eleobj
);
641 setTypeAdd(dstset
,eleobj
);
646 setTypeReleaseIterator(si
);
649 /* Store the resulting set into the target, if the intersection
650 * is not an empty set. */
651 dbDelete(c
->db
,dstkey
);
652 if (setTypeSize(dstset
) > 0) {
653 dbAdd(c
->db
,dstkey
,dstset
);
654 addReplyLongLong(c
,setTypeSize(dstset
));
656 decrRefCount(dstset
);
657 addReply(c
,shared
.czero
);
659 signalModifiedKey(c
->db
,dstkey
);
662 setDeferredMultiBulkLength(c
,replylen
,cardinality
);
667 void sinterCommand(redisClient
*c
) {
668 sinterGenericCommand(c
,c
->argv
+1,c
->argc
-1,NULL
);
671 void sinterstoreCommand(redisClient
*c
) {
672 sinterGenericCommand(c
,c
->argv
+2,c
->argc
-2,c
->argv
[1]);
675 #define REDIS_OP_UNION 0
676 #define REDIS_OP_DIFF 1
677 #define REDIS_OP_INTER 2
679 void sunionDiffGenericCommand(redisClient
*c
, robj
**setkeys
, int setnum
, robj
*dstkey
, int op
) {
680 robj
**sets
= zmalloc(sizeof(robj
*)*setnum
);
682 robj
*ele
, *dstset
= NULL
;
683 int j
, cardinality
= 0;
685 for (j
= 0; j
< setnum
; j
++) {
686 robj
*setobj
= dstkey
?
687 lookupKeyWrite(c
->db
,setkeys
[j
]) :
688 lookupKeyRead(c
->db
,setkeys
[j
]);
693 if (checkType(c
,setobj
,REDIS_SET
)) {
700 /* We need a temp set object to store our union. If the dstkey
701 * is not NULL (that is, we are inside an SUNIONSTORE operation) then
702 * this set object will be the resulting object to set into the target key*/
703 dstset
= createIntsetObject();
705 /* Iterate all the elements of all the sets, add every element a single
706 * time to the result set */
707 for (j
= 0; j
< setnum
; j
++) {
708 if (op
== REDIS_OP_DIFF
&& j
== 0 && !sets
[j
]) break; /* result set is empty */
709 if (!sets
[j
]) continue; /* non existing keys are like empty sets */
711 si
= setTypeInitIterator(sets
[j
]);
712 while((ele
= setTypeNextObject(si
)) != NULL
) {
713 if (op
== REDIS_OP_UNION
|| j
== 0) {
714 if (setTypeAdd(dstset
,ele
)) {
717 } else if (op
== REDIS_OP_DIFF
) {
718 if (setTypeRemove(dstset
,ele
)) {
724 setTypeReleaseIterator(si
);
726 /* Exit when result set is empty. */
727 if (op
== REDIS_OP_DIFF
&& cardinality
== 0) break;
730 /* Output the content of the resulting set, if not in STORE mode */
732 addReplyMultiBulkLen(c
,cardinality
);
733 si
= setTypeInitIterator(dstset
);
734 while((ele
= setTypeNextObject(si
)) != NULL
) {
738 setTypeReleaseIterator(si
);
739 decrRefCount(dstset
);
741 /* If we have a target key where to store the resulting set
742 * create this key with the result set inside */
743 dbDelete(c
->db
,dstkey
);
744 if (setTypeSize(dstset
) > 0) {
745 dbAdd(c
->db
,dstkey
,dstset
);
746 addReplyLongLong(c
,setTypeSize(dstset
));
748 decrRefCount(dstset
);
749 addReply(c
,shared
.czero
);
751 signalModifiedKey(c
->db
,dstkey
);
757 void sunionCommand(redisClient
*c
) {
758 sunionDiffGenericCommand(c
,c
->argv
+1,c
->argc
-1,NULL
,REDIS_OP_UNION
);
761 void sunionstoreCommand(redisClient
*c
) {
762 sunionDiffGenericCommand(c
,c
->argv
+2,c
->argc
-2,c
->argv
[1],REDIS_OP_UNION
);
765 void sdiffCommand(redisClient
*c
) {
766 sunionDiffGenericCommand(c
,c
->argv
+1,c
->argc
-1,NULL
,REDIS_OP_DIFF
);
769 void sdiffstoreCommand(redisClient
*c
) {
770 sunionDiffGenericCommand(c
,c
->argv
+2,c
->argc
-2,c
->argv
[1],REDIS_OP_DIFF
);