RiversJin commented on code in PR #2828:
URL: https://github.com/apache/kvrocks/pull/2828#discussion_r1998063098


##########
src/commands/cmd_key.cc:
##########
@@ -356,6 +356,30 @@ class CommandDel : public Commander {
   }
 };
 
+class CommandDelPrefix : public Commander {
+  public:
+    Status Execute(Server *server, Connection *conn,
+                   std::vector<std::string> args) override {
+      if (args.size() != 2) {
+        return {Status::RedisParseErr,
+                "wrong number of arguments for 'delprefix' command"};
+      }
+  
+      std::string prefix = args[1];
+      auto db = conn->GetNamespace();
+      auto keys = server->storage->GetKeysWithPrefix(db, prefix);
+  
+      int deleted_count = 0;
+      for (const auto &key : keys) {

Review Comment:
   Perhaps using Rocksdb's deleterange interface would be better?



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