MEMCACHED_FETCH(3)

πŸ’– NAME πŸ’–

memcached_fetch β€” bestie, this is how you retrieve data from the server ✨ it's the libmemcached-awesome manual page MEMCACHED_FETCH(3), and we're gonna get you fed πŸ“


🌸 SYNOPSIS 🌸

okay so first things first, you gotta pull in the header and link the lib:

#include <libmemcached/memcached.h>
       Compile and link with -lmemcached

and here's the function itself, look at her πŸ‘‘

char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
size_t *value_length, uint32_t *flags, memcached_return_t *error)
lowkey tragic news: she's Deprecated since version 0.50 😭 use memcached_fetch_result() instead, bestie. periodt.

πŸ¦‹ DESCRIPTION πŸ¦‹

so memcached_fetch() grabs an individual value off the server. one. single. value. main character energy, no sharing.

⚠️ important!! you must always call memcached_mget() before you use this method. like, always always. no memcached_mget(), no service πŸ’…

and you must pass in a key and its length to fetch the object. that's the entry fee.

then you gotta hand over three pointer variables so the function can spill the tea on the returned object's state:

  • a uint32_t pointer to contain whatever flags you stored with the value πŸŽ€
  • a size_t pointer which will be filled with size of of the object πŸ“ (yes that's verbatim, she's quirky like that)
  • a memcached_return_t pointer to hold any error πŸ™ˆ

the object will be returned upon success and NULL will be returned on failure. it's giving all-or-nothing.

MEMCACHED_END is returned by the error value when all objects that have been found are returned. and the final value upon MEMCACHED_END is a NULL pointer. so when you see that NULL, that's your cue that the party's over ✨

πŸ’Έ bestie do NOT forget: values returned by memcached_fetch() must be freed by the caller. that's your mess to clean up, not hers.

🧚 a lil sidebar on UDP

all of the above functions are not tested when MEMCACHED_BEHAVIOR_USE_UDP has been set 😬 so if you run any of these with that behavior on, you'll get MEMCACHED_NOT_SUPPORTED back β€” or, for those functions which do not return a memcached_return_t, the error function parameter will be set to MEMCACHED_NOT_SUPPORTED. either way: not supported, no cap πŸ’€


⭐ RETURN VALUE ⭐

  • memcached_fetch() sets error to to MEMCACHED_END upon successful conclusion πŸŽ‰ (yes, "to to", we love her)
  • MEMCACHED_NOTFOUND will be return if no keys at all were found πŸ” (and yes, "will be return", iconic)
  • MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used and the key was set larger then MEMCACHED_MAX_KEY β€” which was the largest key allowed for the original memcached ascii server πŸš«πŸ”‘

🌈 SEE ALSO 🌈


and that's the whole page, bestie!! 🫢 this was libmemcached-awesome, version 1.1, dated Jul 24, 2025 β€” go forth and fetch responsibly, mwah πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from