mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Optimize the performance of msetnx command by call lookupkey only once (#11594)
This is a small addition to #9640 It improves performance by avoiding double lookup of the the key.
This commit is contained in:
parent
d2d6bc18eb
commit
884ca601b2
@ -553,6 +553,7 @@ void mgetCommand(client *c) {
|
|||||||
|
|
||||||
void msetGenericCommand(client *c, int nx) {
|
void msetGenericCommand(client *c, int nx) {
|
||||||
int j;
|
int j;
|
||||||
|
int setkey_flags = 0;
|
||||||
|
|
||||||
if ((c->argc % 2) == 0) {
|
if ((c->argc % 2) == 0) {
|
||||||
addReplyErrorArity(c);
|
addReplyErrorArity(c);
|
||||||
@ -568,11 +569,12 @@ void msetGenericCommand(client *c, int nx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setkey_flags |= SETKEY_DOESNT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 1; j < c->argc; j += 2) {
|
for (j = 1; j < c->argc; j += 2) {
|
||||||
c->argv[j+1] = tryObjectEncoding(c->argv[j+1]);
|
c->argv[j+1] = tryObjectEncoding(c->argv[j+1]);
|
||||||
setKey(c,c->db,c->argv[j],c->argv[j+1],0);
|
setKey(c, c->db, c->argv[j], c->argv[j + 1], setkey_flags);
|
||||||
notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id);
|
notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id);
|
||||||
}
|
}
|
||||||
server.dirty += (c->argc-1)/2;
|
server.dirty += (c->argc-1)/2;
|
||||||
|
Loading…
Reference in New Issue
Block a user