ltagliamonte-dd commented on code in PR #2827:
URL: https://github.com/apache/kvrocks/pull/2827#discussion_r2006126575


##########
src/commands/cmd_key.cc:
##########
@@ -553,6 +553,26 @@ 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()};
+
+    *output = conn->Map({{redis::BulkString("type"), 
redis::BulkString(RedisTypeNames[metadata.Type()])},
+                         {redis::BulkString("size"), 
redis::Integer(metadata.size)},
+                         {redis::BulkString("ttl"), 
redis::Integer(metadata.expire)},
+                         {redis::BulkString("flags"), 
redis::Integer(metadata.flags)},
+                         {redis::BulkString("version"), 
redis::Integer(metadata.version)}});

Review Comment:
   @PragmaTwice For the sideloading use case when IsSingleKVType() you will 
need version to perform the key update. So the only "useless" field would be 
size in that case, am I wrong?



-- 
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]

Reply via email to