PragmaTwice commented on code in PR #2827:
URL: https://github.com/apache/kvrocks/pull/2827#discussion_r2008589034


##########
src/commands/cmd_key.cc:
##########
@@ -553,6 +553,32 @@ class CommandSort : public Commander {
   SortArgument sort_argument_;
 };
 
+class CommandKMetadata : public Commander {
+ public:
+  Status Execute(engine::Context &ctx, Server *srv, Connection *conn, 
std::string *output) override {
+    redis::Database redis(srv->storage, conn->GetNamespace());
+    std::string &key = args_[1];
+    std::string nskey = redis.AppendNamespacePrefix(key);
+
+    Metadata metadata(kRedisNone, false);
+    auto s = redis.GetMetadata(ctx, RedisTypes::All(), nskey, &metadata);
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    if (metadata.IsSingleKVType()) {
+      *output = conn->Map({{redis::BulkString("type"), 
redis::BulkString(metadata.TypeName())},
+                           {redis::BulkString("expire"), 
redis::Integer(metadata.expire)},
+                           {redis::BulkString("flags"), 
redis::Integer(metadata.flags)}});
+    } else {
+      *output = conn->Map({{redis::BulkString("type"), 
redis::BulkString(RedisTypeNames[metadata.Type()])},

Review Comment:
   ```suggestion
         *output = conn->Map({{redis::BulkString("type"), 
redis::BulkString(metadata.TypeName())},
   ```



-- 
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-unsubscr...@kvrocks.apache.org

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

Reply via email to