libmemcached 中 memcached_get() 的问题

发布于 2024-09-24 10:27:11 字数 323 浏览 13 评论 0原文

memcached_get (memcached_st *ptr,
               const char *key, size_t key_length,
               size_t *value_length,
               uint32_t *flags,
               memcached_return_t *error);

为什么需要在这里传递参数“size_t key_length”和“size_t *value_length”?我认为可以直接通过key获取值。

谁能帮忙告诉我原因,谢谢。

memcached_get (memcached_st *ptr,
               const char *key, size_t key_length,
               size_t *value_length,
               uint32_t *flags,
               memcached_return_t *error);

Why need to pass the params "size_t key_length" and "size_t *value_length" here ? I think the value can be fetched by key directly.

who can help to tell me the reason, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮是我掰弯的 2024-10-01 10:27:11

key 参数是一个指向您想要从 memcache 获取的信息的标识符的指针。 key_length 告诉 memcached_get() 函数您的标识符数据有多长。

如果 libmemcache API 假设 key 参数指向的数据是以 NULL 结尾的字符串,那么我们就不需要传入 key_length 参数。但如果不做这样的假设,API 允许我们使用以 NULL 结尾的字符字符串以外的数据作为键(例如,UTF-16 字符串或二进制数)。

The key parameter is a pointer to an identifier for the information you want to get from memcache. The key_length tells the memcached_get() function how long your identifier data is.

If the libmemcache API assumed that the data pointed to by the key parameter was a NULL-terminated string of characters, then we wouldn't need to also pass in the key_length parameter. But by not making that assumption the API allows us to use data other than NULL-terminated char strings as keys (for example, UTF-16 strings, or binary numbers).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文