Skip to content

Commit 5619f51

Browse files
committed
Add the KEYDB.MEXISTS command, see issue Snapchat#203
1 parent d99d06b commit 5619f51

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/db.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,13 @@ void existsCommand(client *c) {
683683
addReplyLongLong(c,count);
684684
}
685685

686+
void mexistsCommand(client *c) {
687+
addReplyArrayLen(c, c->argc - 1);
688+
for (int j = 1; j < c->argc; ++j) {
689+
addReplyBool(c, lookupKeyRead(c->db, c->argv[j]));
690+
}
691+
}
692+
686693
void selectCommand(client *c) {
687694
long id;
688695

src/help.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,12 @@ struct commandHelp {
13251325
"Rename a hash key, copying the value.",
13261326
4,
13271327
"6.5.3"
1328-
}
1328+
},
1329+
{ "KEYDB.MEXISTS",
1330+
"key [key ...]",
1331+
"Determine if a key exists",
1332+
0,
1333+
"6.5.12" },
13291334
};
13301335

13311336
#endif

src/server.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ struct redisCommand redisCommandTable[] = {
247247
"read-only fast @keyspace",
248248
0,NULL,1,-1,1,0,0,0},
249249

250+
{"keydb.mexists",mexistsCommand,-2,
251+
"read-only fast @keyspace",
252+
0,NULL,1,-1,1,0,0,0},
253+
250254
{"setbit",setbitCommand,4,
251255
"write use-memory @bitmap",
252256
0,NULL,1,1,1,0,0,0},

src/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,7 @@ void getCommand(client *c);
28222822
void delCommand(client *c);
28232823
void unlinkCommand(client *c);
28242824
void existsCommand(client *c);
2825+
void mexistsCommand(client *c);
28252826
void setbitCommand(client *c);
28262827
void getbitCommand(client *c);
28272828
void bitfieldCommand(client *c);

0 commit comments

Comments
 (0)