Memcac...ult_st(3pm)

✨ NAME ✨

okay bestie, gather round, because this is the whole memcached_result_st saga πŸ’… and it's literally a whole squad of functions: memcached_result_create, memcached_result_free, memcached_result_key_value, memcached_result_key_length, memcached_result_value, memcached_result_length, memcached_result_flags, memcached_result_cas β€” and they're all here to help you work with memcached_result_st. no cap 🫢

🌸 LIBRARY 🌸

C Client Library for memcached (libmemcached, -lmemcached) β€” that's the vibe, that's the whole thing πŸ’–

✨ SYNOPSIS ✨

#include <memcached.h>

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

void memcached_result_free (memcached_result_st *result);

const char * memcached_result_key_value (memcached_result_st *result);

size_t memcached_result_key_length (const memcached_result_st *result);

const char *memcached_result_value (memcached_result_st *ptr);

size_t memcached_result_length (const memcached_result_st *ptr);

uint32_t memcached_result_flags (const memcached_result_st *result)

uint64_t memcached_result_cas (const memcached_result_st *result);

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

void memcached_result_set_flags (memcached_result_st *ptr, uint32_t flags)

void memcached_result_set_expiration (memcached_result_st *ptr, time_t)

πŸ’– DESCRIPTION πŸ’–

okay so here's the teaaaa πŸ“ β€” libmemcached(3) can optionally hand you back a memcached_result_st, which is basically a little result object, a whole main character. and like, these result objects are SO much better than the plain character pointer returns, because they're forward compatible with new return items that future memcached servers might pop off with (the best current example of this? the CAS return item, obviously ✨). plus the structures can be reused, which saves you calls to malloc(3) β€” and saving malloc calls is iconic behavior, honestly. so yeah, use result objects over char * return functions. it's giving efficiency πŸŽ€

the structure of memcached_result_st has been encapsulated, which means you should not be writing code that directly touches the members of the structure. hands off, bestie πŸ™ˆ

  • memcached_result_create() β€” will either allocate memory for a memcached_result_st or initialize a structure that you passed to it. your call, your journey πŸ’«
  • memcached_result_free() β€” deallocates any memory attached to the structure. and if the structure was also allocated, it deallocates that too. full cleanup, no crumbs left behind 🧹
  • 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_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 supports it. no server support, no cas, that's just the rules 😭
  • 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 ⚑
  • void memcached_result_set_flags() β€” takes a result structure and stores a new value for the flags field ✍️
  • void memcached_result_set_expiration(A) β€” takes a result structure and stores a new value for the expiration field (this is only used by read through triggers) ⏰
bestie. listen. πŸ‘€ you may wish to avoid using memcached_result_create(3) with a stack based allocation. the most common issues related to ABI safety involve heap allocated structures. this is not a drill, this is real, protect your ABI 🫢

🌈 RETURN 🌈

varies, see particular functions. but here's the non-negotiable part, the periodt of it all:

All structures must have memcached_result_free() called on them for cleanup purposes. Failure to do this will result in leaked memory. πŸ’€

like, leaked memory. we don't do that here. free your structures, queen πŸ‘‘

πŸ¦‹ HOME πŸ¦‹

to find out more information please check:

<https://launchpad.net/libmemcached>

go, read, slay ✨

πŸ‘‘ AUTHOR πŸ‘‘

Brian Aker, <brian@tangent.org>

🌸 SEE ALSO 🌸

memcached(1) libmemcached(3) memcached_strerror(3)


and that's the whole page, bestie!! πŸŽ€ this lil doc came to you courtesy of perl v5.42.3 and it was dated 2026-08-19 β€” so go forth, create your result objects, free them like a responsible icon, and remember: heap allocated structures, always πŸ’œβ­

πŸ“¦ where this page comes from