Commit f9f48ef6 authored by judeng's avatar judeng Committed by Oran Agra
Browse files

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.

(cherry picked from commit 884ca601)
parent b7b78a2d
......@@ -555,6 +555,7 @@ void mgetCommand(client *c) {
void msetGenericCommand(client *c, int nx) {
int j;
int setkey_flags = 0;
if ((c->argc % 2) == 0) {
addReplyErrorArity(c);
......@@ -570,11 +571,12 @@ void msetGenericCommand(client *c, int nx) {
return;
}
}
setkey_flags |= SETKEY_DOESNT_EXIST;
}
for (j = 1; j < c->argc; j += 2) {
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);
}
server.dirty += (c->argc-1)/2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment