From cfcb5ac5c72f06afe78ec091c4e8764d2767df9e Mon Sep 17 00:00:00 2001 From: John Sully Date: Sun, 12 Jul 2020 21:42:11 +0000 Subject: [PATCH] Add the KEYDB.MEXISTS command, see issue #203 Former-commit-id: 5619f515285b08d9c443425de1f3092ae3058d40 --- src/db.cpp | 7 +++++++ src/help.h | 7 ++++++- src/server.cpp | 4 ++++ src/server.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/db.cpp b/src/db.cpp index 770a1c9b4..11816262b 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -683,6 +683,13 @@ void existsCommand(client *c) { addReplyLongLong(c,count); } +void mexistsCommand(client *c) { + addReplyArrayLen(c, c->argc - 1); + for (int j = 1; j < c->argc; ++j) { + addReplyBool(c, lookupKeyRead(c->db, c->argv[j])); + } +} + void selectCommand(client *c) { long id; diff --git a/src/help.h b/src/help.h index 2f692dfc2..c6b614475 100644 --- a/src/help.h +++ b/src/help.h @@ -1325,7 +1325,12 @@ struct commandHelp { "Rename a hash key, copying the value.", 4, "6.5.3" - } + }, + { "KEYDB.MEXISTS", + "key [key ...]", + "Determine if a key exists", + 0, + "6.5.12" }, }; #endif diff --git a/src/server.cpp b/src/server.cpp index c197df741..c38ca1efa 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -247,6 +247,10 @@ struct redisCommand redisCommandTable[] = { "read-only fast @keyspace", 0,NULL,1,-1,1,0,0,0}, + {"keydb.mexists",mexistsCommand,-2, + "read-only fast @keyspace", + 0,NULL,1,-1,1,0,0,0}, + {"setbit",setbitCommand,4, "write use-memory @bitmap", 0,NULL,1,1,1,0,0,0}, diff --git a/src/server.h b/src/server.h index e6d73ab81..7479b4557 100644 --- a/src/server.h +++ b/src/server.h @@ -2822,6 +2822,7 @@ void getCommand(client *c); void delCommand(client *c); void unlinkCommand(client *c); void existsCommand(client *c); +void mexistsCommand(client *c); void setbitCommand(client *c); void getbitCommand(client *c); void bitfieldCommand(client *c);