Skip to content

Commit

Permalink
fix isexist
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshaoyi committed Jun 19, 2024
1 parent 0275cd8 commit 8d838fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/storage/src/redis_strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,9 @@ Status Redis::MSetnx(const std::vector<KeyValue>& kvs, int32_t* ret) {
if (ExpectedStale(value)) {
s = Status::NotFound();
} else {
return Status::InvalidArgument("WRONGTYPE, key: " + kv.key + ", expect type: " + DataTypeStrings[static_cast<int>(DataType::kStrings)] + "get type: " + DataTypeStrings[static_cast<int>(GetMetaValueType(value))]);
// be consistent with redis implementation
exists = true;
break;
}
}
if (s.ok()) {
Expand Down Expand Up @@ -1611,6 +1613,9 @@ rocksdb::Status Redis::IsExist(const storage::Slice& key) {
BaseMetaKey base_meta_key(key);
rocksdb::Status s = db_->Get(default_read_options_, handles_[kMetaCF], base_meta_key.Encode(), &meta_value);
if (s.ok()) {
if (ExpectedStale(meta_value)) {
return Status::NotFound();
}
return Status::OK();
}
return rocksdb::Status::NotFound();
Expand Down
3 changes: 1 addition & 2 deletions src/storage/src/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ Status Storage::MSetnx(const std::vector<KeyValue>& kvs, int32_t* ret) {
Status s;
for (const auto& kv : kvs) {
auto& inst = GetDBInstance(kv.key);
std::string value;
s = inst->Get(Slice(kv.key), &value);
s = inst->IsExist(Slice(kv.key));
if (s.ok() || !s.IsNotFound()) {
return s;
}
Expand Down

0 comments on commit 8d838fc

Please sign in to comment.