PragmaTwice commented on code in PR #1444:
URL: 
https://github.com/apache/incubator-kvrocks/pull/1444#discussion_r1204266158


##########
src/commands/cmd_set.cc:
##########
@@ -283,6 +285,65 @@ class CommandSInter : public Commander {
   }
 };
 
+/*
+ * description:
+ *    syntax:   `SINTERCARD numkeys key [key ...] [LIMIT limit]`
+ *
+ *    limit:    the valid limit is an non-negative integer.
+ */
+class CommandSInterCard : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    auto parse_numkey = ParseInt<int>(args[1], 10);
+    if (!parse_numkey) {
+      return {Status::RedisParseErr, errValueNotInteger};
+    }
+    numkeys_ = *parse_numkey;
+
+    // command: for example, SINTERCARD 2 key1 key2 LIMIT 1
+    if (args.size() == numkeys_ + 4 && util::ToLower(args[numkeys_ + 2]) == 
"limit") {
+      auto parse_limit = ParseInt<int>(args[numkeys_ + 3], 10);
+      if (!parse_limit) {
+        return {Status::RedisParseErr, errValueNotInteger};
+      }
+      limit_ = *parse_limit;
+      if (limit_ < 0) {
+        return {Status::RedisParseErr, errLimitIsNegative};
+      }
+    }
+    return Commander::Parse(args);
+  }
+
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    std::vector<Slice> keys;
+    for (size_t i = 2; i < numkeys_ + 2; i++) {
+      keys.emplace_back(args_[i]);

Review Comment:
   Any user input via redis protocol cannot just make kvrocks crash. That is 
the **principal commitment** of development.
   
   And you cannot enforce users to always use go-redis wrapped command 
functions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to