Skip to content

Commit

Permalink
Avoid unnecessary slot computing in KEYS command. (redis#12843)
Browse files Browse the repository at this point in the history
If not in cluster mode, there is no need to compute slot.

A bit optimization for redis#12754
  • Loading branch information
CharlesChen888 authored Dec 7, 2023
1 parent 8e11f84 commit f2d59c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,12 @@ void keysCommand(client *c) {
long numkeys = 0;
void *replylen = addReplyDeferredLen(c);
allkeys = (pattern[0] == '*' && plen == 1);
if (!allkeys) {
if (server.cluster_enabled && !allkeys) {
pslot = patternHashSlot(pattern, plen);
}
dictIterator *di = NULL;
dbIterator *dbit = NULL;
if (server.cluster_enabled && !allkeys && pslot != -1) {
if (pslot != -1) {
di = dictGetSafeIterator(c->db->dict[pslot]);
} else {
dbit = dbIteratorInit(c->db, DB_MAIN);
Expand Down

0 comments on commit f2d59c4

Please sign in to comment.