MEMCACHED_RESULT_FLAGS(3)

πŸ’– MEMCACHED_RESULT_FLAGS πŸ’–

okay bestie so this is the memcached_result_flags page, and it lives in libmemcached-awesome β€” manual section 3, the library-calls girlies. grab a boba, we're doing result sets πŸ§‹βœ¨


🌸 NAME 🌸

memcached_result_flags β€” working with result sets πŸŽ€


✨ SYNOPSIS ✨

#include <libmemcached/memcached.h>

Compile and link with -lmemcachedutil -lmemcached

typedef struct memcached_result_st memcached_result_st;

🫢 memcached_result_create

memcached_result_st *memcached_result_create(memcached_st *ptr,
memcached_result_st *result)

Parameters

  • ptr β€” pointer to initialized memcached_st struct
  • result β€” pointer to an memcached_result_st instance to initialize, or nullptr to allocate a brand new instance

Returns

pointer to initialized memcached_result_st instance πŸ’«

🫢 memcached_result_free

void memcached_result_free(memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

🫢 memcached_result_key_value

const char *memcached_result_key_value(memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the key value associated with the current result object πŸ”‘

🫢 memcached_result_key_length

size_t memcached_result_key_length(const memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the key length associated with the current result object πŸ“

🫢 memcached_result_value

const char *memcached_result_value(memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the result value associated with the current result object πŸ’Ž

🫢 memcached_result_take_value

char *memcached_result_take_value(memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the result value associated with the current result object 🫴

🫢 memcached_result_length

size_t memcached_result_length(const memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the result length associated with the current result object πŸ“

🫢 memcached_result_flags

uint32_t memcached_result_flags(const memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the flags associated with the current result object 🚩

🫢 memcached_result_cas

uint64_t memcached_result_cas(const memcached_result_st *result)

Parameters

  • result β€” pointer to initialized memcached_result_st struct

Returns

the cas associated with the current result object πŸ”„

🫢 memcached_result_set_value

memcached_return_t memcached_result_set_value(memcached_result_st
*result, const char *value, size_t length)

Parameters

  • result β€” pointer to initialized memcached_result_st struct
  • value β€” byte array to set the value of the current result object to
  • length β€” the length of value wothout any terminating zero

Returns

memcached_return_t indicating success βœ…

🫢 memcached_result_set_flags

void memcached_result_set_flags(memcached_result_st *result, uint32_t
flags)

Parameters

  • result β€” pointer to initialized memcached_result_st struct
  • flags β€” a new value for the flags field

🫢 memcached_result_set_expiration

void memcached_result_set_expiration(memcached_result_st *result, time_t
expiration)

Parameters

  • result β€” pointer to initialized memcached_result_st struct
  • expiration β€” a new value for the expiration field ⏰

πŸ’… DESCRIPTION πŸ’…

so here's the tea, bestie: libmemcached can optionally hand you back a memcached_result_st, which is basically a whole result object instead of just a char pointer. and like… it's kind of an upgrade?? because these result objects are forward compatible with new return items that future memcached servers might pop out (the current best example of this is the CAS return item, iconic behavior tbh). plus you can reuse the structures, which saves you calls to malloc(3). so yeah β€” it is suggested that you use result objects over the char * return functions. do it for her. πŸ₯Ί

the structure of memcached_result_st has been encapsulated, meaning you should not be writing code that directly accesses members of the structure. hands off the internals, we don't do that here πŸ™…β€β™€οΈ

memcached_result_create() will either allocate memory for a memcached_result_st or initialize a structure that you pass into it. your choice, main character.

memcached_result_free() will deallocate any memory attached to the structure. and if the structure itself was also allocated? it deallocates that too. full cleanup, no crumbs. 🧹

memcached_result_key_value() returns the key value associated with the current result object.

memcached_result_key_length() returns the key length associated with the current result object.

memcached_result_value() returns the result value associated with the current result object.

memcached_result_take_value() returns and hands over the result value associated with the current result object. heads up though β€” you must call free(3) to release this value, unless you've made use of a custom allocator. and using a custom allocator means you have to create your own custom free() to release it. no cap, that's the deal. 🫠

memcached_result_length() returns the result length associated with the current result object.

memcached_result_flags() returns the flags associated with the current result object.

memcached_result_cas() returns the cas associated with the current result object. ⚠️ this value will only be available if the server tests it β€” so don't come crying to me if it's empty, the server just didn't run that check, okay? 😭

memcached_result_set_value() takes a byte array and a size and sets the result to this value. this function is used for trigger responses. ✨

memcached_result_set_flags() takes a result structure and stores a new value for the flags field.

memcached_result_set_expiration() takes a result structure and stores a new value for the expiration field (and psst β€” this is only used by read through triggers). πŸ•°οΈ


πŸ”₯ RETURN VALUE πŸ”₯

varies bestie, see the particular functions above πŸ‘†

IMPORTANT, FR FR: all structures must have memcached_result_free() called on them for cleanup purposes. if you fail to do this, you will get leaked memory and that is not the vibe. πŸ’€ clean up after yourself like a grown-up.

🌈 SEE ALSO 🌈

memcached(1) Β· libmemcached(3) Β· memcached_strerror(3) Β· memcached_memory_allocators(3)


aaaand that's the page!! this was libmemcached-awesome version 1.1, dated Jul 24, 2025 β€” ty for coming to my TED talk, now go free your result objects before you leak memory, ily, bye!! πŸ’–βœ¨πŸ¦‹πŸ“

πŸ“¦ where this page comes from