git-hulk commented on code in PR #3317:
URL: https://github.com/apache/kvrocks/pull/3317#discussion_r2656880049


##########
src/types/redis_string.cc:
##########
@@ -182,6 +183,52 @@ rocksdb::Status String::GetEx(engine::Context &ctx, const 
std::string &user_key,
   return rocksdb::Status::OK();
 }
 
+rocksdb::Status String::DelEX(engine::Context &ctx, const std::string 
&user_key, const DelExOption &option,
+                              bool &deleted) {
+  deleted = false;
+  std::string ns_key = AppendNamespacePrefix(user_key);

Review Comment:
   This can prevent returning `deleted=true` along with an error while it fails 
to delete the key from db.
   ```suggestion
     deleted = false;
   
     std::string val;
     std::string ns_key = AppendNamespacePrefix(user_key);
     rocksdb::Status s = getValue(ctx, ns_key, &val);
     if (!s.ok()) return s;
   
     bool matched = false;
     switch (option.type) {
       case DelExOption::NONE:
         matched = true;
         break;
       case DelExOption::IFDEQ:
         matched = option.value == util::StringDigest(val);
       case DelExOption::IFDNE:
         matched = option.value != util::StringDigest(val);
         break;
       case DelExOption::IFEQ:
         matched = option.value == val;
         break;
       case DelExOption::IFNE:
         matched = option.value != val;
         break;
       default:
         return rocksdb::Status::InvalidArgument();
     }
     if (matched) {
       s = storage_->Delete(ctx, storage_->DefaultWriteOptions(), 
metadata_cf_handle_, ns_key);
       deleted = s.ok();
       return s;
     }
   ```



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