PragmaTwice commented on code in PR #3317:
URL: https://github.com/apache/kvrocks/pull/3317#discussion_r2655094030


##########
src/commands/cmd_string.cc:
##########
@@ -108,6 +108,51 @@ class CommandGetEx : public Commander {
   std::optional<uint64_t> expire_;
 };
 
+class CommandDelEX : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    if (args.size() > 4) {
+      return {Status::RedisParseErr, errWrongNumOfArguments};
+    }
+
+    CommandParser parser(args, 2);
+    while (parser.Good()) {
+      if (parser.EatEqICase("ifdeq")) {
+        option = {DelExOption::Type::IFDEQ, GET_OR_RET(parser.TakeStr())};
+      } else if (parser.EatEqICase("ifdne")) {
+        option = {DelExOption::Type::IFDNE, GET_OR_RET(parser.TakeStr())};
+      } else if (parser.EatEqICase("ifeq")) {
+        option = {DelExOption::Type::IFEQ, GET_OR_RET(parser.TakeStr())};
+      } else if (parser.EatEqICase("ifne")) {
+        option = {DelExOption::Type::IFNE, GET_OR_RET(parser.TakeStr())};
+      } else {
+        return {Status::RedisParseErr, errInvalidSyntax};
+      }
+    }
+    return Status::OK();
+  }
+
+  Status Execute(engine::Context &ctx, Server *srv, Connection *conn, 
std::string *output) override {
+    redis::String string_db(srv->storage, conn->GetNamespace());
+    auto s = string_db.DelEX(ctx, args_[1], option, deleted);
+
+    if (!s.ok() && !s.IsNotFound()) {
+      return {Status::RedisExecErr, s.ToString()};
+    }
+
+    if (s.IsNotFound() || (option.type == DelExOption::Type::NONE && 
!deleted)) {
+      *output = redis::Integer(0);
+    } else {
+      *output = redis::Integer(1);
+    }
+    return Status::OK();
+  }
+
+ private:
+  DelExOption option = {DelExOption::Type::NONE, ""};

Review Comment:
   ```suggestion
     DelExOption option;
   ```



-- 
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