MEMCACHED_RESULT_LENGTH(3)

🌸 NAME 🌸

memcached_result_length β€” working with result sets, bestie πŸ’–


✨ 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 without 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 πŸ’–

okay so, plot twist: libmemcached can optionally hand you back a memcached_result_st, which is basically a little result object. ✨ And honestly? The result objects are giving so much more than the plain character pointer return values, because they're forward compatible with new return items that future memcached servers might implement β€” the best current example of this being the CAS return item, iykyk. The structures can also be reused, which saves you on calls to malloc(3). So yeah, it is suggested that you use result objects over char * return functions. No cap. πŸ’…

The structure of memcached_result_st has been encapsulated, so do not go writing code that directly accesses members of the structure. πŸ™ˆ Hands off, bestie.

memcached_result_create() will either allocate memory for a memcached_result_st or will initialize a structure passed to it.

memcached_result_free() will deallocate any memory attached to the structure. And if the structure was also allocated? It will deallocate it too. Cleanup queen. 🧹

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. ⚠️ You must call free(3) to release this value, unless you have made use of a custom allocator. And if you are using a custom allocator, you need to create your own custom free() to release it. Periodt.

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.

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 (this is only used by read through triggers).


😭 RETURN VALUE 😭

Varies, see particular functions. But listen β€” all structures must have memcached_result_free() called on them for cleanup purposes. Failure to do this will result in leaked memory. πŸ’€ Not the leaky memory arc, please.


πŸ¦‹ SEE ALSO πŸ¦‹

memcached(1) libmemcached(3) memcached_strerror(3) ‐ memcached_memory_allocators(3)


and that's the whole page, bestie 🫢 this was libmemcached-awesome version 1.1, dated Jul 24, 2025 β€” go forth and free your result structures, mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from