Generate del events when S*STORE commands delete the destination key.

This commit is contained in:
antirez 2013-01-29 13:43:13 +01:00
parent d2b27f1d96
commit e41d1d77e3

View File

@ -706,7 +706,7 @@ void sinterGenericCommand(redisClient *c, robj **setkeys, unsigned long setnum,
if (dstkey) { if (dstkey) {
/* Store the resulting set into the target, if the intersection /* Store the resulting set into the target, if the intersection
* is not an empty set. */ * is not an empty set. */
dbDelete(c->db,dstkey); int deleted = dbDelete(c->db,dstkey);
if (setTypeSize(dstset) > 0) { if (setTypeSize(dstset) > 0) {
dbAdd(c->db,dstkey,dstset); dbAdd(c->db,dstkey,dstset);
addReplyLongLong(c,setTypeSize(dstset)); addReplyLongLong(c,setTypeSize(dstset));
@ -715,6 +715,9 @@ void sinterGenericCommand(redisClient *c, robj **setkeys, unsigned long setnum,
} else { } else {
decrRefCount(dstset); decrRefCount(dstset);
addReply(c,shared.czero); addReply(c,shared.czero);
if (deleted)
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",
dstkey,c->db->id);
} }
signalModifiedKey(c->db,dstkey); signalModifiedKey(c->db,dstkey);
server.dirty++; server.dirty++;
@ -873,7 +876,7 @@ void sunionDiffGenericCommand(redisClient *c, robj **setkeys, int setnum, robj *
} else { } else {
/* If we have a target key where to store the resulting set /* If we have a target key where to store the resulting set
* create this key with the result set inside */ * create this key with the result set inside */
dbDelete(c->db,dstkey); int deleted = dbDelete(c->db,dstkey);
if (setTypeSize(dstset) > 0) { if (setTypeSize(dstset) > 0) {
dbAdd(c->db,dstkey,dstset); dbAdd(c->db,dstkey,dstset);
addReplyLongLong(c,setTypeSize(dstset)); addReplyLongLong(c,setTypeSize(dstset));
@ -883,6 +886,9 @@ void sunionDiffGenericCommand(redisClient *c, robj **setkeys, int setnum, robj *
} else { } else {
decrRefCount(dstset); decrRefCount(dstset);
addReply(c,shared.czero); addReply(c,shared.czero);
if (deleted)
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",
dstkey,c->db->id);
} }
signalModifiedKey(c->db,dstkey); signalModifiedKey(c->db,dstkey);
server.dirty++; server.dirty++;