cyningsun commented on code in PR #3194:
URL: https://github.com/apache/kvrocks/pull/3194#discussion_r2366167466
##########
src/storage/redis_db.cc:
##########
@@ -208,12 +208,37 @@ rocksdb::Status Database::MDel(engine::Context &ctx,
const std::vector<Slice> &k
}
rocksdb::Status Database::Exists(engine::Context &ctx, const
std::vector<Slice> &keys, int *ret) {
+ *ret = 0;
+
+ if (keys.empty()) {
+ return rocksdb::Status::OK();
+ }
+
std::vector<std::string> ns_keys;
+ std::vector<Slice> slice_keys;
ns_keys.reserve(keys.size());
+ slice_keys.reserve(keys.size());
+
for (const auto &key : keys) {
ns_keys.emplace_back(AppendNamespacePrefix(key));
+ slice_keys.emplace_back(ns_keys.back());
+ }
+
+ std::vector<rocksdb::Status> statuses(slice_keys.size());
+ std::vector<rocksdb::PinnableSlice> pin_values(slice_keys.size());
+ storage_->MultiGet(ctx, ctx.DefaultMultiGetOptions(), metadata_cf_handle_,
slice_keys.size(), slice_keys.data(),
Review Comment:
Hi @PragmaTwice, we actually just discussed this exact point in another
thread. The short answer is that I agree it's a valid optimization. I'll
running additional tests for high cache-hit scenarios before deciding whether
to implement the conditional Get for a single key.
You can see the full discussion here:
https://github.com/apache/kvrocks/pull/3194#discussion_r2365617179
--
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]