MEMCACHED_RESULT_CREATE(3)
π MEMCACHED_RESULT_CREATE π
okay bestie, sit down, hydrate, because we're talking about result sets in libmemcached-awesome and honestly? it's giving organized. this is the <libmemcached/memcached.h> girlies' page, section 3 of the manual, and no cap it's lowkey one of the most useful things in the whole library. let's get into it π«Ά
β¨ NAME β¨
memcached_result_create β 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_ststruct - result β pointer to an
memcached_result_stinstance to initialize, ornullptrto 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_ststruct
πΈ memcached_result_key_value()
const char *memcached_result_key_value(memcached_result_st *result)
Parameters π
- result β pointer to initialized
memcached_result_ststruct
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_ststruct
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_ststruct
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_ststruct
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_ststruct
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_ststruct
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_ststruct
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_ststruct - value β byte array to set the value of the current result object to
- length β the length of value, with no terminating zero in there
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_ststruct - 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_ststruct - expiration β a new value for the expiration field
β¨ DESCRIPTION β¨
so here's the tea β libmemcached can optionally hand you back a memcached_result_st that acts as a whole result object. and bestie, result objects are lowkey superior to the plain character pointer return values β they're forward compatible with new return items that future memcached servers might implement (the best example we have right now? the CAS return item, iconic). plus you can reuse the structures, which means fewer calls to malloc(3). so yeah, it's suggested that you use result objects over char * return functions. periodt. π
the structure of memcached_result_st is encapsulated β you should NOT be writing code that reaches directly into its members. hands off the internals, bestie. π
memcached_result_create() will either allocate memory for a memcached_result_st or initialize a structure that you passed to it. your call, main character. β¨
memcached_result_free() deallocates any memory attached to the structure. and if the structure itself was also allocated? it deallocates that too. double cleanup, we love to see it. π§Ή
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. now listen β you must call free(3) to release this value, unless you made use of a custom allocator. and if you DID use a custom allocator, you need to create your own custom free() to release it. iykyk. π«Ά
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. heads up though: this value will only be available if the server tests it. no server check, no cas, no drama. π
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 one is only used by read through triggers. β°
β¨ RETURN VALUE β¨
varies, bestie β see the particular functions above. π«
but the one universal rule? all structures must have memcached_result_free() called on them for cleanup purposes. failure to do this will result in leaked memory. not a vibe, not the moment, don't do it. π
β¨ SEE ALSO β¨
and that's the whole page, bestie! π¦ this one came from libmemcached-awesome, version 1.1, dated Jul 24, 2025 β go forth and manage your result sets responsibly, and remember: free your structures or they will haunt you. slay πβ¨π
π¦ where this page comes from
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms