PragmaTwice commented on code in PR #3317:
URL: https://github.com/apache/kvrocks/pull/3317#discussion_r2655087350
##########
src/types/redis_string.cc:
##########
@@ -181,6 +182,47 @@ 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, DelExOption &option, bool &deleted) {
+ std::string ns_key = AppendNamespacePrefix(user_key);
+ std::string value;
+ rocksdb::Status s = getValue(ctx, ns_key, &value);
+ if (!s.ok()) return s;
+
+ if (option.type == DelExOption::Type::NONE && option.value == "") {
+ return storage_->Delete(ctx, storage_->DefaultWriteOptions(),
metadata_cf_handle_, ns_key);
+ }
+
+ switch (option.type) {
+ case DelExOption::Type::IFDEQ:
+ if (option.value == util::StringDigest(value)) {
+ deleted = true;
+ }
+ break;
+ case DelExOption::Type::IFDNE:
+ if (option.value != util::StringDigest(value)) {
+ deleted = true;
+ }
+ break;
+ case DelExOption::Type::IFEQ:
+ if (option.value == value) {
+ deleted = true;
+ }
+ break;
+ case DelExOption::Type::IFNE:
+ if (option.value != value) {
+ deleted = true;
+ }
+ break;
+ default:
+ return rocksdb::Status::InvalidArgument();
+ break;
Review Comment:
```suggestion
return rocksdb::Status::InvalidArgument();
```
--
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]