You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/07/04 16:18:18 UTC

[GitHub] [kvrocks] mapleFU commented on a diff in pull request #1539: Fix the inconsistent response behavior with Redis in memory usage command

mapleFU commented on code in PR #1539:
URL: https://github.com/apache/kvrocks/pull/1539#discussion_r1252206882


##########
src/commands/cmd_server.cc:
##########
@@ -289,6 +289,13 @@ class CommandDisk : public Commander {
     auto s = disk_db.Type(args_[2], &type);
     if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
 
+    // Redis returns the Nil string when the key does not exist,
+    // so we need to check the type here to check if the key is not exists.
+    if (type == RedisType::kRedisNone) {
+      *output = redis::NilString();
+      return Status::OK();
+    }
+
     uint64_t result = 0;
     s = disk_db.GetKeySize(args_[2], type, &result);
     if (!s.ok()) return {Status::RedisExecErr, s.ToString()};

Review Comment:
   Sounds ok, RocksDB Snapshot might helps for this, but I after `GetKeySize` would be more easily



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org