MEMCACHED_G...L_CALLBACKS(3)

πŸ’– MEMCACHED_GET_SASL_CALLBACKS πŸ’–

okay bestie, sit down, hydrate, because we're doing libmemcached SASL callback stuff today and it's giving niche but powerful. this page lives in the libmemcached-awesome manual, section 3, and it's literally the whole memcached_get_sasl_callbacks family. let's go πŸ’…


✨ NAME ✨

memcached_get_sasl_callbacks β€” the libmemcached documentation, but make it a group chat 🫢


🌸 SYNOPSIS 🌸

#include <libmemcached/memcached.h>

and like, compile and link with -lmemcached or it simply will not slay.

void memcached_set_sasl_callbacks(memcached_st *ptr,
                                   const sasl_callback_t *callbacks)

Parameters

  • ptr β€” pointer to initialized memcached_st struct
  • callbacks β€” pointer to sasl_callbacks_t holding the callbacks to use
const sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr)

Parameters

  • ptr β€” pointer to initialized memcached_st struct

Returns

pointer to sasl_callbacks_t holding the callbacks currently used

memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr,
                                                const char *username,
                                                const char *password)

Parameters

  • ptr β€” pointer to initialized memcached_st struct
  • username β€” (yes bestie, the original leaves this one blank. iconic of it, honestly πŸ™ˆ)
  • password β€” (same deal, also blank. we simply do not elaborate.)

Returns

memcached_return_t indicating success

memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr)

Parameters

  • ptr β€” pointer to initialized memcached_st struct

Returns

memcached_return_t indicating success


πŸ¦‹ DESCRIPTION πŸ¦‹

so libmemcached lets you plug in your own callback functions that libsasl uses to do SASL authentication. you're the main character, you bring the callbacks. πŸŽ€

⚠️ okay IMPORTANT: SASL requires the memcached binary protocol. no binary protocol, no SASL, no exceptions. and you have to specify the callbacks before you connect to the server. before. not during. not after. before. πŸ’€

memcached_set_sasl_auth_data() is the lil helper function that defines the basic functionality for you β€” so convenient, so cute β€” but heads up: it will store the username and password in memory. if you go this route, you have to call memcached_destroy_sasl_auth_data() before calling memcached_free() or you get a memory leak. we do not leak. leaking is not the vibe. 🚫

and the flip side, equally important:

🫢 you should NOT call memcached_destroy_sasl_auth_data() if you specified your own callback function with memcached_set_sasl_callbacks(). nope. don't. that's not your data to destroy, bestie.

⭐ RETURN VALUE ⭐

  • memcached_get_sasl_callbacks() returns the callbacks currently used by this memcached handle.
  • memcached_set_sasl_auth_data() returns MEMCACHED_SUCCESS upon success. ✨

🌈 SEE ALSO 🌈


and that's the whole page, bestie. go forth, authenticate responsibly, and remember: destroy your auth data only when it's yours to destroy. πŸ‘‘

mwah πŸ’– this was libmemcached-awesome, version 1.1, dated Jul 24, 2025 β€” catch you in the next manpage, periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from