git-hulk commented on PR #3024:
URL: https://github.com/apache/kvrocks/pull/3024#issuecomment-2975050928

   > @git-hulk @PragmaTwice Hi, I have a question about the string set in 
single mode that why some characters miss after `AppendNamespacePrefix`
   > 
   > ```c++
   > rocksdb::Status String::Set(engine::Context &ctx, const std::string 
&user_key, const std::string &value,
   >                             StringSetArgs args, std::optional<std::string> 
&ret) {
   >   uint64_t expire = 0;
   >   info("Set key: {}, value: {}, expire: {}, type: {}, get: {}, keep_ttl: 
{}", user_key, value, args.expire,
   >        static_cast<int>(args.type), args.get, args.keep_ttl);
   >   std::string ns_key = AppendNamespacePrefix(user_key);
   >   info("Set key with namespace: {}, value: {}, expire: {}, type: {}, get: 
{}, keep_ttl: {}", ns_key, value, args.expire,
   >        static_cast<int>(args.type), args.get, args.keep_ttl);
   > 
   >   bool need_old_value = args.type != StringSetType::NONE || args.get || 
args.keep_ttl;
   >   if (need_old_value) {
   >     std::string old_value;
   >     uint64_t old_expire = 0;
   >     auto s = getValueAndExpire(ctx, ns_key, &old_value, &old_expire);
   >     if (!s.ok() && !s.IsNotFound() && !s.IsInvalidArgument()) return s;
   >     // GET option
   >     if (args.get) {
   >       if (s.IsInvalidArgument()) {
   >         return s;
   >       }
   >       if (s.IsNotFound()) {
   >         // if GET option given, the key didn't exist before: return nil
   >         ret = std::nullopt;
   >       } else {
   >         // if GET option given: return The previous value of the key.
   >         ret = std::make_optional(old_value);
   >       }
   >     }
   >     // NX/XX option
   >     if (args.type == StringSetType::NX && s.ok()) {
   >       // if NX option given, the key already exist: return nil
   >       if (!args.get) ret = std::nullopt;
   >       return rocksdb::Status::OK();
   >     } else if (args.type == StringSetType::XX && s.IsNotFound()) {
   >       // if XX option given, the key didn't exist before: return nil
   >       if (!args.get) ret = std::nullopt;
   >       return rocksdb::Status::OK();
   >     } else {
   >       // if GET option not given, make ret not nil
   >       if (!args.get) ret = "";
   >     }
   >     if (s.ok() && args.keep_ttl) {
   >       // if KEEPTTL option given, use the old ttl
   >       expire = old_expire;
   >     }
   >   } else {
   >     // if no option given, make ret not nil
   >     if (!args.get) ret = "";
   >   }
   > 
   >   // Handle expire time
   >   if (!args.keep_ttl) {
   >     expire = args.expire;
   >   }
   > 
   >   // Create new value
   >   std::string new_raw_value;
   >   Metadata metadata(kRedisString, false);
   >   metadata.expire = expire;
   >   metadata.Encode(&new_raw_value);
   >   new_raw_value.append(value);
   >   return updateRawValue(ctx, ns_key, new_raw_value);
   > }
   > ```
   > 
   > 
![image](https://private-user-images.githubusercontent.com/38518057/455327323-aa4bebf9-2e32-45b8-a721-610e35ba215d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTAwNDc0NDMsIm5iZiI6MTc1MDA0NzE0MywicGF0aCI6Ii8zODUxODA1Ny80NTUzMjczMjMtYWE0YmViZjktMmUzMi00NWI4LWE3MjEtNjEwZTM1YmEyMTVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA2MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNjE2VDA0MTIyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRmODIxNGE2Njk4NDhkYzljMTFkN2MyZjNlZWEzNzVkMDk4NDk4YmFhMjk4ZjQ1OGY1YjhiODM1N2IyZDFjMGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.1CdgjzjMYOF-MXJFQPGP0gMi4ujaiJKUqpEGrreq5Vk)
   
   @Genuineh, I'm sorry for not quite understanding what the characters are 
missing.


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